Advertisement
Intermediate TypeScript, Migrating JavaScript to TypeScript

When migrating, why is it common to start with a lenient tsconfig and gradually tighten strictness flags rather than enabling 'strict': true immediately?

Short answer

Enabling full strict mode on an existing large JavaScript codebase typically surfaces hundreds or thousands of pre-existing implicit-any and null-safety issues all at once, which is overwhelming to fix in one pass — gradually enabling individual strict flags (starting with…

Save TypeScript mock interview
Advertisement
AModel answer
Enabling full strict mode on an existing large JavaScript codebase typically surfaces hundreds or thousands of pre-existing implicit-any and null-safety issues all at once, which is overwhelming to fix in one pass — gradually enabling individual strict flags (starting with noImplicitAny, then strictNullChecks, etc.) lets a team fix issues incrementally without blocking all other work.
// Migration path over several stages:
// Stage 1: { "strict": false, "noImplicitAny": true }
// Stage 2: add { "strictNullChecks": true }
// Stage 3: eventually { "strict": true }
Real-world example
Rolling out strict mode across a large team's codebase over several sprints instead of one disruptive, blocking change.
Likely follow-ups
  • Which individual strict-mode sub-flags tend to surface the most errors first in a typical migration?
Related topics