TypeScript Strict Mode Migration
15 items · Technical · Hard difficulty · 2 hours
Incrementally migrate to TypeScript strict mode, file-by-file.
-
Create migration branch and back up tsconfig
Open a new Git branch and save a copy of tsconfig.json to revert if needed.
-
Run initial full type check (tsc --noEmit) and save error list
Capture current compiler errors so you can measure progress during migration.
-
Add //@ts-nocheck to files you will migrate later
Temporarily silence type errors per file so you can focus on one file at a time.
-
Enable noImplicitAny in tsconfig.json
Turn on the flag under compilerOptions to detect implicit any usages.
-
Fix implicit any errors by adding explicit types
Add parameter and variable types or use 'unknown' before narrowing to specific types.
-
Run tsc and adjust types iteratively after fixes
Re-run the compiler frequently to catch dependent type errors as you change types.
-
Enable strictNullChecks in tsconfig.json
Enable to force explicit handling of null and undefined across the codebase.
-
Audit nullable values and use optional chaining or checks
Add null checks, defaults, or narrow types to safely handle nullable values.
-
Enable strictPropertyInitialization in tsconfig.json
Require class properties to be initialized or explicitly marked as definite.
-
Initialize properties in constructors or use definite assignment (!) carefully
Prefer initializing properties; use '!' only when you're certain the value will be set.
-
Enable noImplicitReturns in tsconfig.json
Detect functions that might exit without returning a value to avoid runtime bugs.
-
Run incremental file migrations: remove //@ts-nocheck and fix each file
Uncomment a single file, fix all type errors, run tsc, then remove the comment and commit.
-
Add explicit return types to exported functions and public APIs
Document intent and improve downstream type checking for consumers.
-
Update lint and CI to enforce strict checks
Enable typescript-eslint rules and run tsc --noEmit in CI to prevent regressions.
-
Run full type check, remove temporary scaffolding, and merge branch
Run tsc, run tests, remove remaining //@ts-nocheck comments, then merge when green.
Printed from TickYouOff — the interactive version tracks your progress and can be shared with others.