Why You Should Enable TypeScript Strict Mode
TypeScript's `strict` flag enables a group of checks that catch real bugs before they reach production. Here's what it turns on and why each check matters.
Adding "strict": true to your tsconfig.json is one of the highest-ROI changes you can make to a TypeScript project.
Definition
TypeScript Strict Mode
An umbrella compiler flag that enables strictNullChecks, noImplicitAny, and several other checks that catch whole categories of runtime bugs at compile time.
What strict enables
The flag is an umbrella for several individual checks:
| Check | What it catches |
|---|---|
strictNullChecks | Prevents treating null / undefined as valid values |
noImplicitAny | Forces explicit types on function parameters |
strictFunctionTypes | Catches unsound function-parameter covariance |
strictPropertyInitialization | Ensures class properties are always assigned |
The most impactful one: strictNullChecks
Without this flag, TypeScript allows code like:
const user = getUser(); // returns User | null
console.log(user.name); // compiles fine — crashes at runtime
With it, TypeScript forces you to handle the null case:
if (user) {
console.log(user.name); // safe
}
"Strict mode doesn't make TypeScript harder — it makes your bugs visible before shipping."
Enabling it incrementally
If you are adding strict mode to a large existing codebase, start with just strictNullChecks to avoid a wall of errors. Fix those, then enable the remaining checks one at a time.
New projects should always start with "strict": true — it's far cheaper to enforce from day one.