11 migration and tooling

Migrating a JavaScript codebase is not a big bang event TypeScript lets you check files one at a time

Table of Contents

Rename gradually

Rename a file from .js to .ts Fix the errors in that file Repeat Start with leaf modules that have few dependents

Do not turn on every strict flag on day one for a large legacy tree Start with noImplicitAny and tighten as you go

checkJs

TypeScript can check JavaScript files without renaming them The handbook documents this under “Type Checking JavaScript Files” Use it to find errors before committing to a full rename

JSDoc

JSDoc comments give the checker type hints in plain JavaScript This is the lowest-friction way to start The official JSDoc reference lists which tags are understood

Build tools

The compiler strips types and emits JavaScript Bundlers can do the same with their own TypeScript plugins The handbook explicitly treats tool specific setup as out of scope Read the tool’s own docs for the exact config

Rule that never changes: types are erased Runtime validation still belongs in the program

Posted