Repo of the Day
philipwalton/modern-web-types: TypeScript types for new web platform APIs that aren't yet in lib.dom.
Published: Sep 21, 2026
Open repository ↗TypeScript types for new web platform APIs that aren't yet in lib.dom. - philipwalton/modern-web-types
Summary
modern-web-types provides TypeScript type definitions for web platform APIs that have shipped in at least one stable browser but are not yet included in TypeScript's built-in lib.dom.d.ts. The types are produced by running the same generator Microsoft uses for its official DOM lib, but with the two-engine requirement relaxed to one, so the output is strictly additive to what TypeScript already ships.
What it is useful for
TypeScript's policy is to wait for an API to land in two or more browser engines before adding it to lib.dom. In practice, that means widely available features (for example, recently shipped APIs that have only reached Chrome or Safari) have no official types, so consumers either hand-write declarations or chase single-feature @types/dom-* packages.
modern-web-types fills that gap with generated, complete libraries for five environments:
modern-web-types(or/dom) for the browserDOMlibmodern-web-types/webworkerfor dedicated, shared, and service workermodern-web-types/serviceworker(replaces@types/serviceworker)modern-web-types/sharedworker(replaces@types/sharedworker)modern-web-types/audioworklet(replaces@types/audioworklet)
The repository regenerates these libs every Monday via a GitHub Actions workflow that re-pins the upstream generator and entry types registry, so newly shipped APIs land in the package on the following Monday without manual tracking.
How engineers can use it
The README's recommended approach for most web projects is to install the package under the @typescript/lib-dom alias, which is the name TypeScript resolves when loading its DOM library:
npm install --save-dev @typescript/lib-dom@npm:modern-web-types
On TypeScript 6 or newer, you also need to enable the libReplacement flag in tsconfig.json:
{
"compilerOptions": {
"libReplacement": true
}
}
For TypeScript 4.5–5.x, library replacement is the default and no flag is required.
For worker or worklet environments, the README documents an alternative: drop the corresponding entry from compilerOptions.lib and reference the entry point under types, for example "types": ["modern-web-types/webworker"]. The package calls out a documented caveat here: if your project does not already set types, adding it disables TypeScript's automatic inclusion of every @types/* package in node_modules, so only the packages you list will be picked up. Apache-2.0 license; full generator details, scripts, and report metrics are in the repository's report.md and pkg/ directories.