A small CLI utility that helps with incrementally converting your project to typescript or for adding new rules (strictNullChecks, noImplicitAny, etc...) to existing typescript project
-
- First
tscfcrun will output files without errors
- First
-
- Command
tscfc --updatewill automatically include those files to tsconf
- Command
-
- After that, each
tscfc --updatechecks files against tsconf files (from step 2.) and show user if anything is broken- 3.1. If there are no broken files, then Ok. User's changes didn't affect any files in tsconf
- 3.2. If there are files without error, tscfc will add them to tsconf.
- 3.3. If there are broken files (files in tsconf now have errors), it will output errors and exit code 1 (fail tests)
- After that, each
npm i -D tscfcRun from terminal:
Usage: tscfc --project TSCONFIG_PATH SRC_PATH
Example: tscfc ./index.ts --project ../App/tsconfig.strict.json ../App/src
--project path to your tsconfig.json
--verbose print all logs, usefull for debugging
--update include successfiles to tsconf
--remaining print all remaining files
Note: In order to check javascript files, please include allowJS: true to tsconfig.
If you want to incrementally enforce some rules (e.g. noImplicitAny, strictNullChecks) create
tsconfig.strict.json alongside with your tsconfig.json. Then add to tsconfig.strict.json:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true
}
}in package json add pretest script, which will automatically runs
before your test, to check if you broke something or not, even before test.
{
//...
"scripts": {
"pretest": "tscfc --project ./tsconfig.strict.json ./src"
}
//...
}