Skip to content

Strict Mode

In one line

Strict mode (strict: true in tsconfig) enables a family of strict type-checking options including noImplicitAny, strictNullChecks, and more.

In simple words

Strict mode is a shorthand that enables multiple strict type-checking options at once. Setting strict: true in tsconfig.json turns on: noImplicitAny, strictNullChecks, strictFunctionTypes, strictBindCallApply, strictPropertyInitialization, noImplicitThis, and alwaysStrict.

Strict mode catches the most common sources of runtime errors: implicit any values, null/undefined access, incorrect this binding, and uninitialized class properties. It is the recommended default for all new TypeScript projects.

While strict mode may produce more compiler errors initially, it leads to more robust, self-documenting code. The errors it catches are almost always real bugs or design issues.

Example

typescript
// With strict: true
function greet(name: string) {
  console.log(name.toUpperCase());
}
greet(null); // Error: Argument of type 'null' not assignable to 'string'

let x; // Error: Variable 'x' implicitly has 'any' type

Strict mode catches null arguments and implicit any declarations.

Related terms

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary