TypeScript Is Missing 433 Web API Types
On September 14, 2026 a gap report published by the modern-web-types project put a number on something frontend teams have felt for years. Relax TypeScript's browser-engine requirement by exactly one engine, and the DOM library gains 433 interfaces, 96 type aliases, 214 global variables, 9 global functions, and 311 members added to 80 existing interfaces — none of which lib.dom.d.ts declares today. The WebWorker scope adds another 144 interfaces on top of that.
That gap is not a bug. It is policy, and it is worth understanding before reaching for as any.
The problem: the types trail the platform by design
TypeScript's DOM types are generated by Microsoft's TypeScript-DOM-lib-generator, and the shipped @types/web documentation states the rule plainly: the package "only has APIs which have passed a certain level of standardization and are available in at least two of the most popular browser engines."
Two engines is a defensible line for a default standard library. It keeps the compiler from vouching for APIs that later get renamed or withdrawn. But it also means every API still in its first-engine phase is invisible to the type checker. The current gap report covers WebXR anchors, layers and depth information; Web Bluetooth and WebHID; the orientation, acceleration and gravity sensors; Background Fetch and Background Sync; on-device language detection, translation and summarization; digital goods and payment APIs; speech recognition. The code runs in the browser, and the editor still shows a red squiggle.
The usual responses are a cast to any, which discards every guarantee on that call, or a hand-written declare global block that quietly drifts away from the spec.
What changed
modern-web-types, a project by Philip Walton, runs the exact pipeline Microsoft runs — same generator, same web platform data — but with the threshold set to one stable engine instead of two, then diffs the two outputs. What ships is a set of stand-in replacements for TypeScript's built-in libs, with entry points for DOM, WebWorker, ServiceWorker, SharedWorker and AudioWorklet, regenerated automatically every week. Version 0.5.0 landed on September 14, 2026, adding the container and visibility-state performance entry types after the W3C registry moved from ReSpec to Bikeshed.
It plugs in through a mechanism TypeScript has supported since 4.5: a package published under the name @typescript/lib-<name> replaces the matching built-in lib.
npm install --save-dev @typescript/lib-dom@npm:modern-web-typesOn TypeScript 6 the lookup has to be requested explicitly:
{
"compilerOptions": {
"target": "es2023",
"lib": ["es2023", "dom", "dom.iterable"],
"libReplacement": true
}
}After that, a one-engine API type-checks like any other. The visibility-state performance entry is a good example — it has no place in the default PerformanceTimelineEntryTypeMap, so the observer callback below is untyped territory without the replacement lib:
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntriesByType("visibility-state")) {
console.log(entry.name, entry.startTime);
}
});
observer.observe({ type: "visibility-state", buffered: true });Caveats that matter in production
Types are not support. One engine means one engine. The compiler stops objecting; the API can still be absent in Safari or Firefox. Feature detection and progressive enhancement stay mandatory — arguably more so now, because the type system no longer pushes back on your behalf.
`libReplacement` is about to flip. TypeScript 5.8 introduced the flag with a default of true and a note that the default may change. Issue #62214 is closed and committed: TypeScript 6.0 defaults it to false, aligning with the native TypeScript 7 compiler, which already does. Setting it explicitly is not optional going forward.
The replacement is whole-lib. These are stand-in replacements for the built-in libs, strictly additive relative to what TypeScript already covers — but the project's weekly regeneration cadence becomes part of your build's surface area. Pin the version and review upgrades like any other dependency.
Some references degrade to `any`. The current report lists seven unresolved type references emitted as any, including ContactAddress, SVGPathSegment, DigitalGoodsService and TimeRanges, from upstream definition gaps or renames.
Takeaway
The two-engine rule protects the default; it should not quietly decide which platform features a team is allowed to consider. Measuring the gap turns it from folklore into a number — 433 interfaces in DOM scope alone — and libReplacement turns the decision into one line of configuration that a reviewer can see. Adopt it deliberately, keep the feature detection, and set libReplacement explicitly before TypeScript 6 makes that choice for you.
Primary source: philipwalton/modern-web-types