Strict TypeScript
Critical rules
strict: trueis the floor. Also enablenoUncheckedIndexedAccess,exactOptionalPropertyTypes,verbatimModuleSyntax,erasableSyntaxOnly, and related unused/fallthrough flags.- Ban
any/as/ non-null assertions in source. Narrow with guards, discriminated unions, or Zod. - Install
@total-typescript/ts-resetsoJSON.parseisunknown. - Prefer
satisfiesandas constover loose object typing; avoid barrels and erasable-syntax violations (enum, param properties). - Enforce with
@typescript-eslint/strict-type-checkedat'error'. - Before editing tsconfig or patterns, read references/tsconfig.md and references/type-patterns.md.
Workflow
- Audit
tsconfig.jsonagainst the required flags in references/tsconfig.md. - Add
reset.d.tsimporting@total-typescript/ts-reset. - Enable strict ESLint type-checked rules — see references/eslint-and-build.md.
- Replace
as/anywith guards, unions, or Zod; brand confusable IDs. - Prefer direct imports over barrels; profile with
tsc --extendedDiagnosticsif compile is slow. - Confirm
tsc --noEmitand ESLint pass clean.
Resources
- references/tsconfig.md — required flags and explanations. Read when configuring.
- references/type-patterns.md — narrowing, ts-reset, type-fest, branded types. Read when fixing unsafe code.
- references/eslint-and-build.md — ESLint, barrels, build tools, rationalizations. Read when enforcing in CI.
Validation
- [ ] Supplementary strict flags all enabled
- [ ]
ts-resetinstalled viareset.d.ts - [ ] No
any/asin source (fixtures aside); narrowing is typed - [ ]
satisfies/as constfor literal configs - [ ] Strict type-checked ESLint rules are
'error' - [ ] No hot-path barrel files;
tsc --noEmitclean
Constraints
- Prototypes may trade safety for speed; runtime input parsing belongs in
validation-boundary. - Related:
pattern-enforcement,validation-boundary,fn-args-deps,result-types.