Enabling strict Incrementally
What you'll learn: How to adopt TypeScript's strict mode in an existing codebase by enabling individual compiler flags one at a time, rather than all at once.
The Challenge of Adopting strict
When you have an existing TypeScript codebase that wasn't built with strict: true, flipping that single switch can instantly reveal hundreds or even thousands of type errors. This is overwhelming and blocks development.
The incremental approach lets you gain strict mode's benefits gradually by enabling each underlying flag separately, fixing errors one category at a time.
The Individual Flags Behind strict
Remember that strict: true is actually a shorthand that enables multiple flags:
noImplicitAnystrictNullChecksstrictFunctionTypesstrictBindCallApplystrictPropertyInitializationnoImplicitThisalwaysStrictuseUnknownInCatchVariables
Each can be toggled independently.
Recommended Migration Order
Start with the easiest wins:
alwaysStrict— Just adds"use strict"to output; no type errorsnoImplicitAny— Forces explicit parameter types; often reveals real bugsstrictBindCallApply— Type-checks.bind(),.call(),.apply()properlynoImplicitThis— Requires explicitthistyping in functionsstrictNullChecks— The big one; makesnull/undefinedexplicit (most errors)strictFunctionTypes— Enforces contravariance; rare breaking changesstrictPropertyInitialization— Requires class properties to be initializeduseUnknownInCatchVariables— Changescatch (e)fromanytounknown
The Process
Enable one flag, fix all resulting errors in that category, commit, then move to the next. This keeps pull requests manageable and lets you learn each strictness feature deeply before moving on.
Analogy: It's like tightening security on a building one floor at a time—you can still operate while improving, rather than locking everything down overnight and blocking all access.
Key Takeaway: Adopt strict mode incrementally by enabling and fixing individual compiler flags one at a time, making migration manageable in large codebases.