TypeScript Best Practices

Chapter 1 · Practice 5 of 6

Move to TypeScript 7 by clearing the 6.0 deprecations first

From Compiler settings and TypeScript 7

Why it matters

TypeScript 7.0 is the compiler ported to Go. The TypeScript team reports typical full builds 8 to 12 times faster than 6.0 on large projects, lower peak memory in every project they measured, and the time to the first error in the editor on the VS Code codebase falling from about 17.5 seconds to under 1.3 seconds. The type checking logic matches TypeScript 6.0, so the upgrade is mostly about configuration.

A safe path:

  1. Upgrade to TypeScript 6.0 and fix every deprecation warning. Options like baseUrl, target: es5, downlevelIteration, moduleResolution: node and esModuleInterop: false are hard errors in 7.0.
  2. Set types and rootDir explicitly, as 6.0 recommends.
  3. Install TypeScript 7 with npm install -D typescript and run npx tsc.
  4. Check the tools that use TypeScript's programmatic API. TypeScript 7.0 ships without one, so tools such as typescript-eslint keep running on 6.0. The team recommends installing @typescript/typescript6 through an npm alias for them.

Projects that rely on Vue, Svelte, Astro, MDX or Angular template checking should stay on TypeScript 6.0 for editor features until those integrations support 7.

Do

  • Fix all TypeScript 6.0 deprecation warnings before installing 7.0
  • Replace baseUrl prefixes with paths entries relative to the project root
  • Keep TypeScript 6 installed under an alias for tools that need the compiler API

Avoid

  • Hiding 6.0 deprecations with ignoreDeprecations and forgetting them: 7.0 removes those options