$ npx convert-js-to-ts --projectDir=. --entrypoint=src/index.js
Usage: npx convert-js-to-ts [options]
Convert JavaScript Project to TypeScript
Options:
-V, --version output the version number
-p, --projectDir <string> path/to/project
-e, --entrypoint <string> path/to/entrypoint/in/project ex: src/index.ts
--outputDir <string|undefined> path/to/output/dir, by default use projectDir
--reconvertTs reconvert exist ts files (default: false)
--eslint run eslint for converted files (default: false)
-h, --help display help for command
- Configure eslint for typescript and run this cli with --eslint flag
- rename
.js
to.ts
(using git) - replace
require()
withimport
- replace
module.exports
withexport {}
orexport default
- run eslint for converted files
- fix bug related to remove comments
- improve import & export conversion
- convert to ts that is ready to compile
MIT