Course contentsShow
← TypeScript
Lesson 1180 of 1,79628. tsconfig in DepthFree lesson

What strict Mode Does

Understanding the strict flag as a shorthand that enables multiple type-checking flags at once.

What strict Mode Does

You'll learn: How the strict compiler flag in tsconfig.json acts as a master switch that enables multiple type-checking options at once.

The Master Safety Switch

In TypeScript's tsconfig.json, you've seen individual flags like strictNullChecks that control specific type-checking behaviors. But there's a shortcut that enables many of these safety features all at once: the strict flag.

Think of strict like a car's "Sport Mode" button—instead of manually adjusting the suspension, throttle response, and steering individually, one switch activates a preset combination of settings. Similarly, strict is a meta-flag that simultaneously enables a collection of stricter type-checking rules.

What strict Actually Does

When you set "strict": true in your tsconfig.json, TypeScript automatically enables these individual flags:

  • strictNullChecks — Makes null and undefined distinct types that must be explicitly handled
  • strictFunctionTypes — Ensures function parameter types are checked correctly (contravariance)
  • strictBindCallApply — Type-checks .bind(), .call(), and .apply() methods accurately
  • strictPropertyInitialization — Requires class properties to be initialized in the constructor
  • noImplicitAny — Prevents variables from implicitly having the any type
  • noImplicitThis — Flags errors when this has an implicit any type
  • alwaysStrict — Emits "use strict" in JavaScript output and parses files in strict mode

You could enable each of these individually, but strict gives you the whole safety package in one declaration.

Why Use It

Enabling strict mode is the recommended default for new TypeScript projects. It catches more potential bugs at compile time, makes your code more predictable, and prevents common JavaScript footguns. You can always selectively disable specific strict checks if needed, but starting with strict: true gives you maximum type safety by default.

Key Takeaway: The strict flag is a convenience option that enables multiple strict type-checking flags simultaneously, giving you comprehensive type safety without configuring each rule individually.