What ts-migrate Does
You'll learn: How ts-migrate automatically converts JavaScript files to TypeScript at scale by adding type annotations across an entire codebase.
The Large-Scale Migration Problem
When you have hundreds or thousands of JavaScript files to convert to TypeScript, manually adding types to each file becomes impractical. You'd face weeks or months of tedious work just to get your codebase into a compilable TypeScript state.
ts-migrate is an automated migration tool created by Airbnb that solves this problem by batch-converting JavaScript files to TypeScript with minimal human intervention.
How ts-migrate Works
Think of ts-migrate as a "first draft" generator for your TypeScript migration. It:
- Renames files from
.jsto.ts(or.jsxto.tsx) - Adds type annotations where it can infer them
- Inserts
anytypes where it can't determine the correct type - Adds
@ts-ignorecomments to suppress errors it can't resolve - Runs multiple codemods (code transformations) in sequence
The tool prioritizes getting your code to compile over perfect type safety. It's designed to create a working baseline that you can iteratively improve.
The Philosophy
ts-migrate embraces the "make it work, then make it right" approach. Rather than trying to achieve perfect types from day one—which might never happen—it gets you to a compilable state immediately. From there, you can gradually replace any types with proper annotations, remove @ts-ignore suppressions, and tighten type safety over time.
This is far more practical for large teams than attempting a perfect migration upfront.
Key Takeaway: ts-migrate automates the bulk conversion of JavaScript to TypeScript by adding type annotations where possible and using any/suppressions where necessary, creating a compilable baseline for gradual improvement rather than perfect types.