@ovos-media/ts-strictify
v1.6.7
Published
Enable gradual TypeScript strict
Downloads
2,956
Readme
ts-strictify
Runs TypeScript in strict mode on your changed files.
Background
TBD
How it works
When you start working on a new feature or fixing a bug, you will modify the code base in one way or another. ts-strictify
will take a look at these changes - and only these changes (!) and will complain, if the files you have touched are not strict compliant.
That is different than TypeScript works. You could check a single file against the compiler, but the compiler would also look up the imports and the imports of the imports. Not exactly what you want, when you are looking for incrementally update path.
Head over to https://cschroeter.net/moving-to-strict-typescript/ for more insights.
Install
With yarn
:
yarn add --dev @ovos-media/ts-strictify
With npm
:
npm install --save-dev @ovos-media/ts-strictify
Usage
With yarn
:
yarn ts-strictify
You can also disable a compiler flag, for example you want to disable strictNullChecks
yarn ts-strictify --strictNullChecks false
You can find a list of all available options here
.
With npx
:
npx @ovos-media/ts-strictify
With npm
:
- Add
"ts-strictify": "ts-strictify"
to the scripts section ofpackage.json
. npm run ts-strictify
Pre-Commit Hook
You can run ts-strictify
as a pre-commit hook using husky
.
yarn add --dev husky
In package.json
, add:
"husky": {
"hooks": {
"pre-commit": "ts-strictify"
}
}
Options
Options:
--help Show help [boolean]
--version Show version number [boolean]
--noImplicitAny [boolean] [default: true]
--noImplicitThis [boolean] [default: true]
--alwaysStrict [boolean] [default: true]
--strictBindCallApply [boolean] [default: true]
--strictNullChecks [boolean] [default: true]
--strictFunctionTypes [boolean] [default: true]
--strictPropertyInitialization [boolean] [default: true]
--noUncheckedIndexedAccess [boolean] [default: false]
--noEmit [boolean] [default: true]
--targetBranch [string] [default: "master"]
--commitedFiles [boolean] [default: true]
--stagedFiles [boolean] [default: true]
--modifiedFiles [boolean] [default: true]
--untrackedFiles [boolean] [default: true]
--createdFiles [boolean] [default: true]
Supported SCM
- Git