What is strict mode in TypeScript

· Category: TypeScript

Short answer

Strict mode is a tsconfig.json setting that enables a family of stricter type-checking options to catch more errors at compile time.

How it works

Setting strict: true enables noImplicitAny, strictNullChecks, strictFunctionTypes, strictBindCallApply, strictPropertyInitialization, noImplicitThis, and alwaysStrict. These options enforce that types are explicit, nulls are handled, functions are checked contravariantly, and classes initialize properties.

Example

With strictNullChecks, the following produces an error unless guarded:

function getLength(s: string | null) {
  return s.length; // Error: Object is possibly null
}

Why it matters

Strict mode is the single most impactful configuration for type safety. New projects should always enable it. Existing projects can adopt it incrementally by enabling individual flags.