Advertisement
Beginner TypeScript, Migrating JavaScript to TypeScript

What is the recommended first step when migrating an existing JavaScript project to TypeScript?

Short answer

Add a tsconfig.json with 'allowJs': true and 'checkJs': false (or start with a very lenient config), rename files gradually from .js to .ts rather than all at once, and let the project compile alongside existing JavaScript during the transition.

Save TypeScript mock interview
Advertisement
AModel answer
Add a tsconfig.json with 'allowJs': true and 'checkJs': false (or start with a very lenient config), rename files gradually from .js to .ts rather than all at once, and let the project compile alongside existing JavaScript during the transition.
// tsconfig.json — lenient starting point
{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": false,
    "strict": false,
    "noImplicitAny": false
  }
}
Real-world example
Migrating a large legacy Express or React codebase file-by-file over several sprints instead of a risky big-bang rewrite.
Likely follow-ups
  • Why is a gradual, file-by-file migration generally safer than converting an entire codebase at once?
Related topics