Description
Coming over from https://github.com/eslint/rewrite/pull/117/files#r1742735782: TypeScript's compilerOptions.strict
"enables a wide range of type checking behavior that results in stronger guarantees of program correctness. Turning this on is equivalent to enabling all of the strict mode family options... You can then turn off individual strict mode family checks as needed." Enabling strict
is generally a TypeScript best practice. It's generally considered a must-have whenever possible: i.e. except when a pre-existing project is too large to easily migrate.
The two most impactful strict options are:
noImplicitAny
: tells TypeScript to produce type errors if it can't infer a parameter or variable from its default or initial values- Example:
const log = value => console.log(value.toUpperCase()); log(123);
produces a type error only withstrictNullChecks
- Example:
strictNullChecks
: makesnull
andundefined
their own types, rather than implicitly allowed (the "billion dollar mistake")- Example:
let value: string = null; console.log(value.toUpperCase());
produces a type error only withstrictNullChecks
strictNullChecks
in particular is necessary for a lot of typescript-eslint rules to run properly: search the intentionally obnoxiously namedallowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing
in typescript-eslint.io
- Example:
I understand there maybe some reluctance to enable strict
on this repo. I think there was a discussion prior to #117 but I can't find it on demand. Are there strong reasons not to enable strict
here?