Combining Strictness Options for Maximum Safety
What you'll learn: How to strategically enable TypeScript's strictness flags to maximize type safety in new projects versus gradual migrations.
The Strategic Approach
When it comes to TypeScript's strictness options, you have two very different scenarios: starting fresh versus migrating existing code. Think of it like building a house versus renovating one — new construction can follow the strictest building codes from day one, while renovations need a phased approach.
New Projects: Go Strict Immediately
For brand-new TypeScript projects, the best practice is simple: enable strict: true from the start. This single flag activates all major strictness options:
noImplicitAnystrictNullChecksstrictFunctionTypesstrictBindCallApplystrictPropertyInitializationnoImplicitThisalwaysStrictuseUnknownInCatchVariables
When starting fresh, you write code with these guardrails, not around them. There's no migration pain because you're not fighting existing patterns.
Optional additions: Consider also enabling noUncheckedIndexedAccess and exactOptionalPropertyTypes for even more safety, though these aren't included in the strict flag.
Gradual Migrations: One Flag at a Time
For existing JavaScript or loosely-typed TypeScript codebases, enabling strict: true immediately would likely produce hundreds or thousands of errors. Here, the strategy is incremental:
Phase 1: Start with noImplicitAny — it catches the most egregious gaps without changing runtime behavior assumptions.
Phase 2: Add strictNullChecks — this is the biggest leap but catches the most bugs. Tackle it file-by-file or module-by-module.
Phase 3: Enable remaining flags one at a time, fixing errors as you go.
Key insight: Use // @ts-expect-error comments strategically to mark known issues you'll fix later, preventing new violations while cataloging technical debt.
Key Takeaway: New projects should enable strict: true immediately for maximum safety. Existing codebases should migrate incrementally, starting with noImplicitAny, then strictNullChecks, then other flags one at a time.