jscodeshift-typescript-example
jscodeshift-typescript-example copied to clipboard
jscodeshift typescript codemod example
jscodeshift-typescript-example
TypeScript all the way 🚀
Example usage of jscodeshift for TypeScript with TypeScript:
- TypeScript target files *.ts
- TypeScript transformer
- TypeScript test files
- TypeScript fixtures
TypeScript transformer
Strongly typed code and code completion with @types/jscodeshift
Installation
npm i
or
yarn
Run codemod
npx jscodeshift -t ./examples/simple-rename.ts --extensions=ts --parser=ts './**/*.ts' --print --dry
Omit
--dry
to write the transformed source back to disk.
Test
npm test
or
yarn test
Debug
Use the pre-configured VSCode launcher to run tests and debug your transformer.
Behind the scenes
Use @babel/parser
in https://astexplorer.net when working with the jscodeshift's default parser (default: babel
).
Resources & Inspiration
- https://github.com/facebook/jscodeshift/tree/master/sample
- https://github.com/facebook/jscodeshift/blob/master/recipes/retain-first-comment.md
- https://github.com/elliottsj/jscodeshift-typescript-example
- https://astexplorer.net