Contents
In brief
TypeScript 7.1 is in beta. Install with npm install -D typescript@beta.
The headline for day-to-day module work: import attributes (with { type: "json" } and friends) can now be declared on ambient modules — types follow the label, not only the file extension.
Alongside that: source phase imports for WebAssembly and future loaders, a stable es2026 target, a new programmatic API built around snapshots, and further type-check speedups on large codebases.
What happened
Think of a parcel at customs. The box may say .md or .css, but you open it by the stamp: text, raw bytes, or a stylesheet. TypeScript often used declare module "*.css" and trusted the extension. Runtimes care about with { type: "…" }, not the suffix.
In 7.1, ambient modules accept the same with clause. You can write declare module "*" with { type: "css" } and get a CSSStyleSheet, "text" as a string, "bytes" as a Uint8Array. Importing without the required attribute is an error. You no longer need twin patterns for .txt and .md if both mean text.
These declarations are not shipped in TypeScript’s built-in libs — put them in your own project so they do not fight lib.dom or @types/node.
Second: source phase imports — import source SuperFastThing from "./mod.wasm". You get the module after parse/analysis, before its imports load. For WebAssembly that object is a WebAssembly.Module, ready for WebAssembly.instantiate. Dynamic form: import.source("…"). You need a suitable --module (esnext / nodenext / preserve) and esnext in --lib or --target.
es2026 is now a stable --target / --lib. Stabilized APIs include Math.sumPrecise(), Array.fromAsync(), Base64/hex helpers on Uint8Array, and getOrInsert on Map / WeakMap. esnext picks up proposals such as Promise.allKeyed and several Iterator methods.
Separately, a new programmatic API. Entry points are split: typescript/sync, typescript/async, typescript/fs, typescript/ast, plus helpers. API and Program are Disposable — close them explicitly or with using, or you leak on the Go side. Long-lived tools use snapshots (createSnapshot / update): layer a filesystem change and reuse compiler work instead of rebuilding the world. Content mappers make embedded JS/TS in .vue, Svelte, Astro, and similar formats a first-class path.
On performance: after 7.0’s ~10× jump over 6.0, 7.1 beta squeezes memory and wall time further. With four checker threads and --noEmit, mui-docs is about 1.9× faster (memory nearly −50%); vscode about 1.2× time and −17% memory. Internals range from single-file program reuse to denser checker layouts.
Why it matters
Import attributes already live in browsers and bundlers. While types ignored with, it was easy to omit the attribute or get the wrong module shape — CSS Modules by default in a bundler vs CSSStyleSheet in the browser. Attribute-aware ambient types catch that before runtime.
Source phase gives a clear path for wasm plugins without custom loader folklore. Stable es2026 reduces lib surprises on upgrade. The new API and snapshots tell lint authors, language services, and CLIs: build on public entry points, not brittle workarounds.
Less time and RAM on large repos hits the save-and-wait loop harder than any cosmetic syntax change. Monorepos feel that first.
In practice
Install the beta on a branch and compare tsc --noEmit with 7.0 on a representative slice.
- Install:
npm install -D typescript@beta. - If you import JSON, text, bytes, or CSS with
with { type: "…" }, declare ambient modules with the same attributes — and drop duplicate*.md/*.txtpatterns when both mean text. - For wasm, try
import source/import.sourcewith matching--moduleandlib. - In
tsconfig, try"target": "es2026"/"lib": ["es2026", …]and see what no longer needsesnext. - Tool authors: walk through
typescript/sync,using, and snapshots; do not mix objects across snapshots. - For Vue/Svelte/Astro, watch content mappers and
--runExternalCode— that is an explicit trust boundary. - Before promoting to main, skim the announcement’s behavioral changes (DOM
libupdates, stronger distributive type parameters).
| Topic | What to verify |
|---|---|
| Import attributes | Error without with, correct type with with |
| Source phase | wasm + WebAssembly.instantiate |
es2026 |
Needed methods in lib, less stray esnext |
| API / snapshots | dispose / using, FS layer on edits |
| Performance | tsc --noEmit time and RSS vs 7.0 |
Takeaway
TypeScript 7.1 Beta aligns the type system with how modules actually load in 2026: the stamp on the parcel matters more than the suffix on the box.
Add a stable es2026 target, a wasm-friendly source phase, a snapshot-based tool API, and another speed pass on top of 7.0.
Worth putting typescript@beta on a CI branch now — while feedback still shapes the release, not after GA.



Comments