Get types for the latest web APIs as soon as they become widely available!
The default types generator for TypeScript requires manual review for every update, and thus does not provide types for every latest API in a timely manner. types-web
solves this issue by deploying automation by following tools:
@mdn/browser-compat-data
provides which features are supported by which browsers, so that undersupported features can be disabled automatically.browser-specs
provides a full list of web specs, so that every latest feature can be covered.webref
provides IDL code from the specs, so that the features can be properly typed.
See how many types have been added in the changelog.
-
Install the package by
npm i types-web
. -
Include the type files in your
tsconfig.json
orjsconfig.json
:{ "compilerOptions": { // Explicitly exclude "dom" here "lib": ["es2020"] }, "includes": [ // For general scripts: dom* // Web workers: webworker* // Shared workers: sharedworker* // Service workers: serviceworker* // Audio worklets: audioworklet* "node_modules/types-web/baselines/dom*" "*" ] }
To maintain the package by myself without waiting for external reviews.
A feature needs to be supported by more than two major browser engines to be included here, to make sure there is a good consensus among vendors: Gecko (Firefox), Blink (Chrome/Edge), and WebKit (Safari).
If the condition is met but still is not available here, please file an issue.
Not yet. A small part of things still needs manual modification, which is done by files in inputfiles/
directory.
-
To get things setup:
npm i
-
To generate the
.d.ts
filesnpm run build && npm run baseline-accept
-
To test:
npm test