Preview code AST of the target code using AST explorer. To interactively test and update codemods might be helpful to use ndb.
ndb npx jscodeshift -t ./transforms/something.js --extensions=ts --parser=tsx ./src/**/*container.ts
yarn
npx jscodeshift -t ./transforms/[transform].js [files]
- Review changes via
git diff
. Keep what you want, throw it out if you don't. Magic!
When executing codemods, you can configure options like so:
npx jscodeshift -t node_modules/5to6-codemod/transforms/[transform].js [files] --key=value
Transforms will automatically distinguish and pass through Recast config keys via jscodeshift. Official documentation for Recast's configuration can be found here. The following Recast keys are supported:
esprima
inputSourceMap
lineTerminator
quote
range
reuseWhitespace
sourceFileName
sourceMapName
sourceRoot
tabWidth
tolerant
trailingComma
useTabs
wrapColumn
Some TS features might not work because latest release of jscodeshift is not yet published to NPM. facebook/jscodeshift#330