ts-migrate is intended to accelerate the TypeScript migration process. The resulting code will pass the build, but a followup is required to improve type safety. There will be lots of // @ts-expect-error, and any that will need to be fixed over time. In general, it is a lot nicer than starting from scratch.
ts-migrate is designed as a set of plugins so that it can be pretty customizable for different use-cases. Potentially, more plugins can be added for addressing things like improvements of type quality or libraries-related things (like prop-types in React).
https://github.com/airbnb/ts-migrate
We have examples of the three categories of plugins:
-
example-plugin-jscodeshift simply reverses the names of all identifiers.-
example-plugin-text will add a console.log before each return statement.-
example-plugin-ts is a simple TypeScript AST-based plugin, which shows how we can add simple types to the JavaScript code with the usage of TypeScript compiler API.Produces: