"strict": true in tsconfig.json turns on a family of stricter checks at once. It's strongly recommended for all new projects — it catches the bugs TypeScript exists to prevent.
{ "compilerOptions": { "strict": true } }
"strict": true in tsconfig.json turns on a family of stricter checks at once. It's strongly recommended for all new projects — it catches the bugs TypeScript exists to prevent.
{ "compilerOptions": { "strict": true } }
// strictNullChecks — null/undefined are no longer assignable to everything
let name: string = null; // ❌ Error (without strict this compiles, then crashes)
function f(u?: User) { u.name; } // ❌ u is possibly undefined → forces a check
// noImplicitAny — parameters with no inferable type must be annotated
function g(x) {} // ❌ Error: 'x' implicitly has type 'any'
// strictPropertyInitialization — class fields must be initialized
class C { name: string; } // ❌ must init in constructor or mark optional
strictNullChecks is the big one: it separates null/undefined from other types, so the compiler forces you to handle "might be missing" everywhere — eliminating the #1 class of runtime errors ("cannot read property of undefined").
Flip flags on incrementally (strictNullChecks first), fix errors file by file, rather than enabling everything at once on a large legacy project.
Without strict mode, TypeScript still allows many of the unsafe patterns it's meant to prevent (implicit any, unchecked nulls).
Strict mode is where TypeScript delivers most of its value — treat it as the default and only relax individual flags with good reason.