Automating some steps of the conversion of an existing codebase to TypeScript
Wed, Sep 2, 2020 - ~300 Words
Below is a simple script which will take the list of .jsx files (in this case under the app/javascript directory and for each file it will rename it to have a .tsx extension, and then if webpack compiles (which means that the code type checks) and all tests pass, then this rename can be converted. If either fail, then the rename is reversed and the next file is tested. The motivation for this is that in a codebase of some hundreds of JS(X) files, the majority can actually be renamed cleanly, in part as currently we allow the any type implicitly.
Read more →