Course contentsShow
← TypeScript
Lesson 1643 of 1,79637. Migrating JavaScript to TypeScriptFree lesson

What ts-migrate Does

Overview of ts-migrate's automated conversion approach and how it adds type annotations to JavaScript files at scale.

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:

  1. Renames files from .js to .ts (or .jsx to .tsx)
  2. Adds type annotations where it can infer them
  3. Inserts any types where it can't determine the correct type
  4. Adds @ts-ignore comments to suppress errors it can't resolve
  5. 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.