This repository contains a collection of codemod scripts for use with JSCodeshift that help update Flowified JS code.
npm install -g jscodeshiftgit clone https://github.com/flowtype/flow-codemod.gitjscodeshift -t <codemod-script> <path>(but note that individual transforms may require additional options, as documented)- Use the
-doption for a dry-run and use-pto print the output for comparison
- jscodeshift currently uses Babel 5, which fails to parse certain JS idioms. Files that fail to parse will not be transformed, unfortunately.
The following codemods can be found under the transforms directory:
Adds explicit arguments to polymorphic type application expressions, based on errors from Flow. For example,
let map: Map = ...
...becomes
let map: Map<any, any> = ...
This prepares code for an upcoming change to strict type argument processing. For instructions and more info, see documentation in the transform subdirectory.
flow-codemod is MIT licensed, as found in the LICENSE file.