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
- Add
tsconfig.jsonwith lenient settings; rename nothing yet — the build should still work - Rename files to
.tsone at a time, starting with files that have few dependencies (utilities, constants) - Add types incrementally —
anyis an acceptable temporary placeholder, not a failure - Once most files are converted, gradually enable
strict: trueand 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.