Msw/2/Imports
Codemod verified
Official codemod published by a verified account. Learn more.
Following the original msw upgrade guide, there are certain imports that changed their location and/or naming. This codemod will adjust your imports to the new location and naming.
- setupWorkeris now imported from- msw/browser
- restfrom- mswis now named- http
- RestHandlerfrom- mswis now named- HttpHandler
Before
import { rest as caller, RestHandler, setupWorker } from "msw";const handlers: RestHandler[] = [caller.get("/user", (req, res, ctx) => {return res(ctx.json({ firstName: "John" }));}),];
After
import { http as caller, HttpHandler } from "msw";import { setupWorker } from "msw/browser";const handlers: HttpHandler[] = [caller.get("/user", (req, res, ctx) => {return res(ctx.json({ firstName: "John" }));}),];
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community