Migrate a JavaScript project to TypeScript

8 steps · about 4 h 20 min · Intermediate

  1. Plan an incremental migration (guide, TypeScript documentation, 40 min)

    Keep the project runnable while moving files and correcting assumptions in manageable steps.

  2. Include existing JavaScript (reference, TypeScript documentation, 25 min)

    Bring current modules into one program before requiring every file to be TypeScript.

  3. Check JavaScript early (reference, TypeScript documentation, 30 min)

    Surface useful type evidence and defects before renaming files or adding annotations.

  4. Separate checking from building (reference, TypeScript documentation, 25 min)

    Adopt TypeScript analysis without unexpectedly replacing the project's current output pipeline.

  5. Raise strictness deliberately (reference, TypeScript documentation, 35 min)

    Enable stronger guarantees with a visible error budget instead of masking the remaining work.

  6. Narrow uncertain values (guide, TypeScript documentation, 40 min)

    Prove types through runtime checks rather than asserting that external data is already safe.

  7. Type an untyped dependency (guide, TypeScript documentation, 35 min)

    Describe only the imported module surface the project actually relies on.

  8. Remove unsafe gaps (reference, TypeScript documentation, 30 min)

    Find remaining implicit any values and replace them with specific types or explicit boundary validation.