Advertisement
Advanced TypeScript, Migrating JavaScript to TypeScript

How would you incrementally enable 'noImplicitAny' across a large codebase without fixing every error immediately?

Short answer

Enable noImplicitAny globally, but use the 'exclude' array (or per-directory tsconfig overrides via project references / separate tsconfig files) to temporarily exempt not-yet-migrated directories, then progressively shrink that exclusion list as more of the codebase is cleaned…

Save TypeScript mock interview
Advertisement
AModel answer
Enable noImplicitAny globally, but use the 'exclude' array (or per-directory tsconfig overrides via project references / separate tsconfig files) to temporarily exempt not-yet-migrated directories, then progressively shrink that exclusion list as more of the codebase is cleaned up.
// tsconfig.json
{
  "compilerOptions": { "noImplicitAny": true },
  "exclude": ["src/legacy/**"] // temporarily exempted, shrinks over time
}
Real-world example
Tracking and reducing a migration's 'debt' as a shrinking exclude list that the team steadily chips away at.
Likely follow-ups
  • How could you track migration progress numerically, like percentage of files fully typed?
Related topics