C

msw/2/callback-signature

How to Use
Run this codemod on your codebase using one of the following commands

The easiest way to run this codemod without installing anything globally:

Documentation

Following the original msw upgrade guide, the signature of the request handler have changed. This codemod hard replaces the callback signature to the new one and cleans up unused variables.

NOTE: This codemod should be applied after running all the other codemods present in the upgrade-recipe that are related to req, res, ctx objects. On its own, this codemod makes no sense to be run, and will most likely not do what you want.

WARNING

This codemod runs .fixUnusedIdentifiers() on a source file you are running it on. This would remove any unused declarations in the file. This is due to atomicity of this mod, which blindly inserts the callback structure into each msw handler callback and then cleans up the variables that are not used.

Before

ts

After

ts

Before

ts

After

ts

Ready to contribute?

Build your own codemod and share it with the community.