Skip to content
AgileLogics
5 min read

Migrating a JavaScript Codebase to TypeScript

TypeScript allows an incremental migration — plain .js files can coexist with .ts files in the same project via "allowJs": true.

A common approach:

  1. Add a tsconfig.json with "allowJs": true and "strict": false (loose at first).
  2. Rename files to .ts one at a time, starting with the most depended-on/foundational ones.
  3. Fix the type errors surfaced in each file as you go.
  4. Once most of the codebase is converted, gradually enable "strict": true and address the additional errors it reveals.

Trying to enable full strict mode on day one of a large migration usually surfaces too many errors at once to be practical.