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— Makesnullandundefineddistinct types that must be explicitly handledstrictFunctionTypes— Ensures function parameter types are checked correctly (contravariance)strictBindCallApply— Type-checks.bind(),.call(), and.apply()methods accuratelystrictPropertyInitialization— Requires class properties to be initialized in the constructornoImplicitAny— Prevents variables from implicitly having theanytypenoImplicitThis— Flags errors whenthishas an implicitanytypealwaysStrict— 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.