TypeScript 7.1 RC: native API with snapshots, built-in Content Mappers, WASI, and up to 2.2x faster checksLongread · digest for December 5
3D exploded diagram of the modular TypeScript 7.1 RC compiler with a Go core, snapshot layers, a Content Mappers adapter for .vue and .svelte files, and the tsc.wasm module
Longread7 sections≈ 18 min

TypeScript 7.1 RC: native API with snapshots, built-in Content Mappers, WASI, and up to 2.2x faster checks

When TypeScript 7.0 on Go shipped in July 2026, type checking in large projects became about ten times faster. Those numbers looked great, but there was a downside. The ecosystem around the compiler lost its usual hooks. Tools like vue-tsc spent years patching internal JS methods of the old tsc at runtime. You can't patch a native Go binary that easily.

TypeScript 7.1 RC, released on December 4, 2026, closes this gap. The release candidate is already feature-complete. The team plans to ship the stable version in a couple of weeks with only targeted fixes for critical bugs. You can test your project today with npm install -D typescript@rc.

This release brings seven major updates: typed import attributes, source phase imports for WebAssembly, stable ES2026, a modular API with snapshots, built-in Content Mappers, an experimental Wasm package, and new speed and memory optimizations. Let's look at how each part works under the hood and what to watch out for when you upgrade.

Import attributes in ambient modules: clean support for CSS, text, and bytes

Import attributes (with { type: "..." }) tell the browser or runtime how to read an imported file. A browser can't guess by the .json or .css extension because a file over the network might have no extension at all. Writing with { type: "json" } or with { type: "css" } removes any doubt.

Now two new ECMAScript proposals are joining JSON and CSS: Import Text to load a file as a string (with { type: "text" }) and Import Bytes for a raw Uint8Array (with { type: "bytes" }). Previously, to stop TypeScript from complaining about these imports, projects used a global .d.ts file with wildcard ambient declarations like declare module "*.css" or declare module "*.md".

That old approach had three problems. First, the compiler didn't check whether a developer actually wrote with { type: "text" }. If you forgot the attribute, the build passed, but the code crashed at runtime. Second, you had to repeat the same pattern for .txt, .md, .sql, and every new extension, even though the runtime only cares about type, not the file suffix.

The third problem was even worse. A bundler might import .css as CSS Modules (an object with class names) by default, while with { type: "css" } returns a browser CSSStyleSheet. Old extension wildcards couldn't tell those two modes apart.

In TypeScript 7.1, you can write import attributes directly in an ambient module declaration:

// Global .d.ts with no top-level imports or exports
declare module "*" with { type: "css" } {
  const content: CSSStyleSheet;
  export default content;
}

declare module "*" with { type: "text" } {
  const content: string;
  export default content;
}

declare module "*" with { type: "bytes" } {
  const content: Uint8Array;
  export default content;
}

Now the "*" wildcard matches any extension, but only when the matching with attribute is present. If you forget with { type: "text" }, the compiler flags an error right away. Meanwhile, a plain .css import still resolves as CSS Modules.

Keep two details in mind. First, TypeScript doesn't check if a file matched by an ambient declaration actually exists on disk. A typo in the path will be caught later by your bundler or runtime. Second, the team didn't add these patterns to the standard lib.*.d.ts files. Library authors shouldn't include them in published packages either, so end projects can set up global types for their own environment, like browser lib.dom.d.ts or server @types/node.

Source Phase Imports: raw WebAssembly without extra boilerplate

A regular JavaScript import does everything at once: it parses the file, loads dependencies, links exports, and runs the code. With WebAssembly, that flow often gets in the way. You want to get the compiled .wasm module first, pass it an environment manually (such as file permissions via WASI), and only then create a running instance.

To solve this, TC39 is working on Source Phase Imports (currently at Stage 3), and TypeScript 7.1 now supports it. The import source modifier returns the module at an intermediate stage: it's already parsed and validated by the runtime, but not yet linked or executed.

For .wasm, the runtime gives you a WebAssembly.Module object that you can pass directly to WebAssembly.instantiate. In Node.js, this syntax for WebAssembly has worked since version 24.0.0. There is also a dynamic import.source(...) form for lazy loading.

import source SuperFast from "./fast.wasm";
import { WASI } from "node:wasi";

// Create a WASI environment and pass it to the compiled module
const wasi = new WASI({ version: "preview1" });
const inst = await WebAssembly.instantiate(SuperFast, {
  wasi_snapshot_preview1: wasi.wasiImport,
});
wasi.start(inst);

// Dynamically load the same module by path
const dynamicMod = await import.source("./fast.wasm");

// Static and dynamic source imports point to the exact same object
console.log(SuperFast === dynamicMod); // true

Look at the last line. Unlike WebAssembly.instantiate, which creates a new instance on every call, source imports keep reference identity. You can safely use the module as a key in a Map or Set, and === always returns true.

The syntax only allows default imports, so import source { fn } won't work. At the type level, each import gets the new global AbstractModuleSource type from lib.esnext.d.ts. To allow this syntax, set --module in tsconfig.json to esnext, nodenext, or preserve, and add esnext to --lib or --target.

For regular .js files, this feature isn't very useful yet. The standard plans to let you pass AbstractModuleSource into import() to customize loading, but most tools and runtimes don't support that for JS modules. For server-side Wasm on Node.js 24+, however, it's ready to use right now.

Stable es2026 target and new features in lib esnext

The --target es2026 and --lib es2026 options are now stable. This gives you ready-to-use type declarations for methods that are now final in ECMAScript 2026. You no longer need to pull in esnext just to use recent built-in APIs.

Architecture diagram of the new modular TypeScript 7.1 API: seven entry points between JS and Go, immutable Snapshot objects, and a layered virtual file system

Here are the main additions now stable in lib.es2026:

  • Map.prototype.getOrInsert() and getOrInsertComputed() (plus the same methods on WeakMap): these replace the classic pattern where you check has, call set if missing, and then call get.
  • Built-in Base64 and Hex helpers directly on Uint8Array: toBase64(), setFromBase64(), toHex(), setFromHex(), plus static Uint8Array.fromBase64() and Uint8Array.fromHex(). That removes extra utility dependencies for binary protocols and browser buffers.
  • Math.sumPrecise() for adding long arrays of floating-point numbers without losing precision.
  • JSON.rawJSON() and a JSON.parse() overload that exposes the raw substring via context.source, which helps keep large numbers accurate.
  • Error.isError(), Iterator.concat(), and Array.fromAsync() to build an array from an async iterator.

Meanwhile, the draft --lib esnext added fresh TC39 proposals: Promise.allKeyed and Promise.allSettledKeyed (to await a dictionary of promises by object keys instead of array indexes), Iterator.zip and Iterator.zipKeyed, plus chunks, join, and includes on the iterator prototype.

Modular TypeScript 7.1 API: using, snapshots, and layered FS

In older TypeScript, the whole programmatic API lived in one giant typescript object. In 7.1, it's split across seven clean entry points, so bundlers, linters, and IDEs only load what they need.

Entry pointPurpose
typescript/syncSynchronous compiler client: options, type-checker, Program API
typescript/asyncPromise-based asynchronous client
typescript/fsIsolated and layered virtual file systems
typescript/astSyntax tree node types and enum constants (SyntaxKind, ScriptTarget)
typescript/ast/isReady-made type guards for checking AST nodes
typescript/ast/factorycreate* factories and immutable update* functions
typescript/wasmExperimental entry point for the WASI/Wasm build

The key design detail of the new API is the using keyword from Explicit Resource Management (TC39 Stage 4). API, Program, and Snapshot objects now implement Disposable.

Why is this required? When JS asks to create a Program or Snapshot, the Go side allocates real memory and holds internal compiler structures. JavaScript's garbage collector doesn't know about that memory. If you write const program = api.createProgram(...) inside a linter or dev-server rebuild loop without freeing it, the Go process will quietly grow in memory until it crashes.

You have two choices. Either declare resources with using so JavaScript calls [Symbol.dispose]() when leaving the block, or free them manually with api.close(), program.dispose(), and snapshot.dispose(). Once disposed, you can't touch those objects again.

The second pillar of the new API is Snapshot. Batch compilation (build everything from scratch and exit) is simple, but editors and file watchers work differently. Files change one by one every few seconds. A snapshot captures the state of all projects and programs at a specific moment. When a file changes, you don't rebuild the world from scratch. You create a new snapshot on top of the old one with before.update(...).

import { ScriptTarget } from "typescript/ast";
import {
  createFileSystemLayer,
  createFileSystemWithLib,
} from "typescript/fs";
import { API } from "typescript/sync";
import { resolve } from "node:path";

const file = resolve("snapshot-example.ts");

// using guarantees Go-side resources are freed
using api = new API();
using before = api.createSnapshot({
  fileSystem: createFileSystemWithLib([
    [file, 'export const answer: number = "forty-two";'],
  ]),
  createPrograms: [
    {
      rootFiles: [file],
      compilerOptions: {
        strict: true,
        noEmit: true,
        target: ScriptTarget.ES2022,
      },
    },
  ],
});

using p1 = before.operation.createdPrograms[0];
console.log("before:", p1.getSemanticDiagnostics().length); // 1

// Apply a layer with only the changed file on top of the base
using after = before.update({
  fileSystem: createFileSystemLayer([
    [file, "export const answer: number = 42;"],
  ]),
  ensurePrograms: [p1.id],
});

using p2 = after.getProgram(p1.id)!;
console.log("after:", p2.getSemanticDiagnostics().length); // 0
console.log("before:", p1.getSemanticDiagnostics().length); // 1

There are two great details in this example. First, updates are lazy by default. You can batch several update() calls, and the compiler won't recalculate programs until you pass their IDs to ensurePrograms. Second, the old before snapshot stays fully readable alongside after, which makes comparing diagnostics before and after an edit easy. Just never mix AST nodes, symbols, or checkers from different snapshots in the same call.

The typescript/fs module handles virtual files. By default, the compiler reads from the real disk, but you can build any sandbox on top using four helpers:

  1. createFileSystem(files) creates a fully isolated file system with only the files you pass.
  2. createFileSystemWithLib(files) does the same, plus mounts the standard lib.*.d.ts folder as read-only.
  3. createFileSystemLayer(files) adds a thin override layer on top of a base snapshot or host disk.
  4. createFileSystemFromSnapshot(oldSnapshot, extraFSLayer?) carries virtual overlays from an old snapshot to a new one, so an LSP server doesn't re-send unchanged files.

Layers also support removedPaths to hide files from the lower layer, program.emitToString() to get generated JS in memory without writing to disk, and fileNotifications in snapshot.update(). The API doesn't force a file watcher on you: plug in your own and feed change events into snapshots.

Content Mappers: the Volar model inside the compiler

Anyone who has written Vue, Svelte, Astro, or MDX knows the pain: one file mixes HTML templates, styles, and TypeScript blocks. To highlight errors inside templates in editors, Volar turned component files into virtual TypeScript and kept a line-mapping table.

Isometric diagram of Content Mappers in TypeScript 7.1: .vue and .svelte files pass over IPC/JSON-RPC to an external mapper and return virtual TypeScript with a position map

That worked great in editors, but the CLI required hacks. Old TypeScript had no official API for these transforms, so wrappers like vue-tsc had to reach inside the compiler's JS internals or replace it completely. When TypeScript moved to Go in version 7, that fragile bridge vanished.

In TypeScript 7.1, the Volar idea is now built into the compiler via Content Mappers. You bind a mapper to a file extension right in tsconfig.json. When tsc or the language server sees that file (via include or an import), it sends it to an external mapper process over IPC/JSON-RPC, gets back virtual TS code with a position map, and checks types with exact line numbers from your source file.

{
  "compilerOptions": {},
  "contentMappers": [
    {
      "package": "@vue/content-mapper",
      "extensions": [".vue"],
      "options": {
        "target": 3.5
      }
    }
  ]
}

With this setup, regular tsc checks your project without third-party CLI wrappers, though it requires one flag: tsc --runExternalCode. The @vue/content-mapper package above isn't on npm yet; it just shows the config format. Still, early prototypes already exist for six ecosystems (Astro, CSS Modules, Ember, MDX, Svelte, Vue), plus a demo mapper for .html files that checks <script> tags and inline event handlers.

--runExternalCode security and the dynamic import trap

Running tsc used to be a safe, read-only operation. Content Mappers change that: the compiler now launches third-party executable code from node_modules. That's why the CLI won't run mappers without --runExternalCode, and VS Code requires both Workspace Trust and your explicit approval (you can also disable it completely via js/ts.contentMappers.enabled).

A second catch affects projects using --rewriteRelativeImportExtensions. Normally, TypeScript emits a small runtime helper to rewrite extensions in dynamic calls like import(dir + "/foo.ts"). If a content mapper sets both outputExtensions and an include filter, that helper can't reliably guess the final path, so 7.1 throws an error. You can fix this with the new --disableDynamicImportExtensionRewriting flag, which skips the runtime helper while keeping static relative import rewriting working.

There is a fair trade-off here. Until framework teams ship stable mapper packages on npm, you can't drop vue-tsc or svelte-check in production. Still, the TypeScript side of the infrastructure is already in place.

Experimental WebAssembly: tsc.wasm in browsers and WASI

A native Go binary is great on a laptop or in CI, but some places can't run native executables: browsers, online sandboxes, and cloud editors. TypeScript 7.1 fills that gap with the new experimental @typescript/typescript-wasip1-wasm package.

Inside is lib/tsc.wasm, built with Go's standard GOOS=wasip1 GOARCH=wasm target for WASI Preview 1. You can use it in two ways:

  1. As a library in a browser or JS runtime: instantiate it with instantiateWasm and use the programmatic API via typescript/wasm.
  2. As a full WASI command: run tsc in a terminal or start an LSP server inside isolated runtimes like Wasmtime, Wasmer, or the pure-Go wazero runtime.

This build already powers the TypeScript Playground on engine 7.1 and experimental TypeScript support in VS Code for the Web. The package is still marked Experimental, so packaging and setup details may change before final release.

Speed, memory, and what might break on upgrade

After the 10x jump in 7.0, you might think there was little left to squeeze out. Still, the team landed over 80 more optimizations in 7.1 RC. They enabled standard PGO (Profile-Guided Optimization, tuning the binary for real hot paths) and shrank AST and checker metadata structures by moving rare fields out of hot records and capping arena memory by real bytes instead of object counts.

They also added a perfect hash table for keyword lookups, smarter file balancing across checker threads based on shared imports, and parallel signature calculation for dependent files during incremental builds. For editors, LSP messages now encode directly without MarshalJSON overhead, and macOS no longer attaches recursive file watchers to home directories.

Here are the results across five large real-world codebases using the default four type-checker threads and --noEmit.

Type-check time (--noEmit, 4 threads): TS 7.0 vs TS 7.1 RC

Compile time improved across all five codebases, and peak RAM dropped even more sharply. Memory limits are usually what kill builds on CI runners.

Memory usage during type checking: TS 7.0 vs TS 7.1 RC

Type-heavy projects like mui-docs gained the most, cutting both check time and memory use roughly in half. The other codebases also saved real seconds and gigabytes, which helps CI runners with strict RAM limits avoid sudden OOM kills.

Now for the upgrade cost. Aside from regular DOM type updates in lib.d.ts, 7.1 RC introduces stricter checks for distributive conditional types (Stronger Checks When Using Distributive Type Parameters).

When you write T extends U ? X : Y with a bare type parameter T, TypeScript distributes the check over each union member. Previously, inside the branches, the compiler treated the distributed T and the original T as the same type. That leniency let clearly broken code slip through.

type Show<A extends number, B extends A> = `${B} extends ${A}`;

type Issue<A extends number, B extends A> =
  A extends B ? never : Show<A, B>;
//                         ~
// Error: Type 'B' does not satisfy the constraint 'A'.
//   'B' is only assignable to the non-distributed 'A',
//   but 'A' has been distributed here.

// In TS 7.0 this silently compiled to the absurd type "0 extends 1"
type UhOh = Issue<0 | 1, 0>;

The logic is simple: Cat is a subtype of Animal, but a cat isn't a subtype of every specific animal like Dog. Likewise, 0 fits the union 0 | 1, but once A distributes into 0 and 1, the second branch turns B extends A into the nonsense check 0 extends 1.

In TypeScript 7.1, the parameter inside a distributive branch becomes a new, narrower type that no longer satisfies constraints tied to the original A. If this error shows up in your project or type library, you can fix it in two ways: remove the extra constraint from the type signature, or add an explicit conditional check inside the branch to prove the relation to the compiler.

Checklist before testing your project on TypeScript 7.1 RC

  • Install the release candidate in a separate branch with npm install -D typescript@rc and run npx tsc --noEmit.
  • Check for new errors in complex conditional types (distributed parameters) and updated DOM types in lib.d.ts.
  • If you use --rewriteRelativeImportExtensions with content mappers and dynamic import(), check whether you need --disableDynamicImportExtensionRewriting.
  • If you migrate scripts or linters to typescript/sync or typescript/async, wrap API, Program, and Snapshot in using or call dispose() explicitly to avoid Go-side memory leaks.
Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 9