Migrating a JavaScript Project to TypeScript Gradually

Migrating an existing JavaScript codebase to TypeScript doesn’t have to be a rewrite — TypeScript is specifically designed to let you adopt it incrementally, file by file.

{
  "compilerOptions": {
    "allowJs": true,        // lets .js and .ts files coexist during migration
    "checkJs": false,       // start lenient - don't type-check .js files yet
    "strict": false,        // start lenient overall, tighten later
    "outDir": "./dist"
  }
}

A Practical Migration Order

  1. Add tsconfig.json with lenient settings; rename nothing yet — the build should still work
  2. Rename files to .ts one at a time, starting with files that have few dependencies (utilities, constants)
  3. Add types incrementally — any is an acceptable temporary placeholder, not a failure
  4. Once most files are converted, gradually enable strict: true and fix what it surfaces

Trying to achieve full strict-mode compliance on day one across an entire existing codebase is how TypeScript migrations stall out — incremental, file-by-file adoption with lenient settings initially is what actually gets finished.