Strict Mode and Tooling
Enable strict compiler flags, integrate ESLint type-aware rules, and use editor settings that catch bugs before commit.
strict: true enables the compiler's strongest default checks — strictNullChecks, noImplicitAny, strictFunctionTypes, and more. Teams that enable strict early pay a one-time migration cost and avoid years of nullable bugs. Turning strict on in a mature codebase requires incremental file-by-file enablement or @ts-expect-error cleanup sprints.
TypeScript alone does not catch all issues — ESLint with typescript-eslint adds style and some logic rules typecheck misses. Editor format-on-save and CI running tsc --noEmit plus lint form the quality gate before merge.
What strict enables
strictNullChecks separates null and undefined from other types — optional chaining becomes necessary instead of accidental. noImplicitAny errors on untyped parameters and implicit any locals. strictFunctionTypes checks function parameter contravariance on callbacks.
Incremental strict adoption
strictNullChecks and noImplicitAny can be enabled individually before full strict. // @ts-nocheck at file top disables checking — use temporarily during migration, not permanently. prefer @ts-expect-error with comments explaining why.
ESLint with typescript-eslint
typescript-eslint parser reads tsconfig for type-aware rules — no-floating-promises, no-misused-promises, consistent-type-imports. Run eslint in CI alongside tsc. type-aware linting is slower — scope to src/ not entire monorepo if needed.
| Flag | Catches |
|---|---|
| strictNullChecks | null/undefined access |
| noImplicitAny | Untyped params/locals |
| noUncheckedIndexedAccess | undefined array access |
| exactOptionalPropertyTypes | undefined vs missing |
Editor and CI workflow
Enable TypeScript SDK in the editor for the workspace TypeScript version — not an outdated global. CI should run npm run typecheck (tsc --noEmit) on every PR. Pre-commit hooks optional but typecheck in CI is non-negotiable for typed codebases.
- strict: true for new projects
- typescript-eslint for promise and import rules
- tsc --noEmit in CI
- 1strict catches nullable and any bugs
- 2Enable flags incrementally if needed
- 3ESLint complements tsc
- 4Next: typing async and Promises