MSW V2 - Replace printHandlers() calls

verified codemod icon

A new way of calling a passthrough is available in msw v2. This codemod replaces req.passthrough() calls with the new way of doing that using exported function.

MSW
ts-morph
Estimated time saving
5 minutes/occurrence
Change mode
Assistive
Applicability criteria

MSW version >= 1.0.0

Made by
Codemod.com
Codemod.com

Usage →

Codemod CLI:

intalling vs code extension tooltip icon
codemod msw/2/req-passthrough
copy CLI command icon

Codemod VS Code extension:

intalling vs code extension tooltip icon
vs code logo
Run in VS Code

Description

A new way of calling a passthrough is available in msw v2. This codemod replaces req.passthrough() calls with the new way of doing that using exported function.

Example

Before

rest.get('/resource', (req, res, ctx) => {
  return req.passthrough()
})

After

import { passthrough } from 'msw'
rest.get('/resource', (req, res, ctx) => {
  return passthrough()
})

Links for more info