Strict Flags

What strict Turns On

"strict": true is a shortcut that enables a family of checks. Always start new projects with it.

FlagWhat it catches
strictNullChecksnull/undefined not allowed unless in the type
noImplicitAnyparameters and variables that silently become any
strictFunctionTypesunsafe function parameter assignments (contravariance)
strictPropertyInitializationclass properties never assigned
strictBindCallApplywrong arguments to bind/call/apply
useUnknownInCatchVariablescatch (e) is unknown, not any
noImplicitThis, alwaysStrictthis of type any; emits "use strict"

The Same Code Without strict

Example

With strict: false this compiles: find may return undefined, but nothing forces a check, so it crashes at runtime. With strict: true the compiler would report TS18048.

const users = [{ id: 1, name: "Asha" }];

function nameOf(id: number) {
  const user = users.find((u) => u.id === id);
  return user.name.toUpperCase();
}

console.log(nameOf(1));
console.log(nameOf(2));

Output

ASHA
Uncaught TypeError: Cannot read properties of undefined (reading 'name')

Turning Flags On Gradually

Tip: Migrating an old codebase? You can enable "strict": true and temporarily switch off one flag ("strictNullChecks": false), fix files module by module, then remove the override.