Skip to content
Tutorials Center
My learning

Topics

TypeScript Reference ยท Concepts and Comparisons

The TypeScript 7 native compiler

What the Go-based TypeScript 7 compiler changes for you: speed, the same type system, removed options, the editor service, tooling APIs and how to upgrade.

TypeScript 7 is a port of the compiler and language service from JavaScript to Go. The type system is meant to behave the same, so the code you write does not change. What changes is the engine: it runs as a native program, uses several CPU cores at once, and uses much less memory. Type checking large projects that took minutes now takes seconds, and editor features such as completions and go-to-definition respond sooner.

This site runs on TypeScript 7: every runnable example in this reference is type-checked by the native tsc before Node runs it. The command is still tsc and tsconfig.json still configures it, so most projects upgrade by changing one version number.

Terminal
npm install --save-dev typescript@7
npx tsc --noEmit

Try it

TypeScript Same types, same errors

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

TypeScript What runs the output is still Node

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

What is different

  • Speed and memory. Parsing, binding and checking run in parallel across files where the algorithm allows it. Builds with project references use the same idea at project level; see composite and tsc --build.
  • Language service. The editor server speaks the Language Server Protocol, so editors other than VS Code get the same quality of support.
  • Options. Settings that were deprecated in the 6.x line are removed or ignored in 7: expect errors for ancient targets such as es5, for the classic and node10 module resolution modes and for old module formats. Fix the config rather than silencing it. See target and moduleResolution.
  • Defaults. More options have strict, modern defaults, so a short tsconfig.json is now enough for a new project.
  • JavaScript API. The old in-process compiler API (import ts from "typescript" and walking the AST) is not available in the same form. Tools that depend on it, such as some linters, codemods and transformers, need a native-API-based release or run beside an older TypeScript. Plain tsc users are unaffected.
  • Error messages. Almost all text is identical. A few diagnostics changed wording or position, so tests that compare compiler output as text may need an update.

Upgrading

  1. Upgrade to the latest 5.x or 6.x first and fix deprecation warnings there.
  2. Install typescript@7 and run tsc --noEmit. Compare the error count with before.
  3. Remove or replace options the compiler rejects.
  4. Check the tools that import TypeScript as a library (lint plugins, doc generators) for versions that support 7.
  5. If a dependency needs the old API, keep an older typescript installed under another name for that one tool.

Usage notes

  • Same tsconfig.json, same flags. tsc --build, --watch, --noEmit and --showConfig work as before.
  • Types are still erased. Output is plain JavaScript; see Type erasure.
  • Performance work shifts. Slow builds are more often caused by type complexity than by the compiler itself; see Compiler performance.
  • Preview releases were distributed as @typescript/native-preview with a tsgo command before 7 shipped; older notes use that name.
  • Do not mix compilers in one check. CI and the editor should agree on the version, or you will see errors in one and not the other.