TypeScript strict mode
TypeScript's strict mode enables a bundle of compiler flags that produce stricter type checking — noImplicitAny, strictNullChecks, strictFunctionTypes, strictBindCallApply, alwaysStrict, strictPropertyInitialization, noImplicitThis. Enabling strict eliminates entire categories of runtime bugs at compile time by forcing engineers to handle null/undefined explicitly.
Strict mode is the single highest-leverage TypeScript configuration choice. The 'strictNullChecks' alone catches more bugs than any other lint rule because most JavaScript bugs are 'Cannot read property X of undefined'. The cost is upfront: enabling strict on a non-strict codebase surfaces hundreds or thousands of errors that must be fixed before the build passes. The pragmatic migration path: enable strict on new files via override, then per-folder via a directory tsconfig, then globally. Once strict is in place, the type system is doing real work and refactoring becomes dramatically less risky.
Related terms
- Type narrowing
Type narrowing is TypeScript's ability to refine a value's type within a conditional branch based on runtime checks — typeof, instanceof, in operator, equality checks, custom type predicates.
- Discriminated union
A discriminated union is a union type whose variants share a literal-typed property (the discriminant) that uniquely identifies each variant — typically named 'type', 'kind', or 'tag'.
- Branded type
A branded type is a TypeScript pattern that distinguishes structurally-identical types by adding a phantom 'brand' property — UserId and ProductId can both be string at runtime but cannot be assigned to each other at compile time.