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

The @ts-ignore and any Strategy

Understanding ts-migrate's liberal use of suppressions and any types to ensure the codebase compiles immediately.

The @ts-ignore and any Strategy

You'll learn how ts-migrate achieves instant compilation by liberally suppressing type errors rather than fixing them.

The Philosophy Behind ts-migrate

When you run ts-migrate on a large JavaScript codebase, its primary goal isn't to create perfectly-typed TypeScript—it's to make your code compile immediately. Think of it as putting a cast on a broken leg: it doesn't heal the injury, but it stops the bleeding so you can walk to the hospital.

ts-migrate achieves this by following two main strategies:

  1. Suppress errors with @ts-ignore comments wherever TypeScript complains
  2. Add any type annotations to parameters, properties, and return types that would otherwise trigger noImplicitAny errors

Why This Approach Works for Migration

The tool makes a pragmatic trade-off: compilation now, type safety later. Instead of forcing you to fix thousands of type errors before your first successful build, ts-migrate says "we'll mark these problems and you can fix them incrementally."

This is especially valuable in large codebases where:

  • You need to prove TypeScript works before committing
  • The team needs time to learn TypeScript gradually
  • You want to ship the migration in stages rather than all at once

The Technical Reality

Every place where TypeScript would emit an error, ts-migrate adds a suppression comment. Every untyped parameter becomes param: any. The result? Your codebase compiles, but you've essentially told TypeScript "don't check anything here."

This isn't ideal—you've lost type safety in those spots—but you've gained a foundation. Now you can gradually remove suppressions and replace any with real types, file by file, function by function.

Key Takeaway: ts-migrate prioritizes getting your codebase compiling over achieving type safety, using suppressions and any as temporary scaffolding that you'll replace during gradual migration.