types-web
v0.1.19types-web
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.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.
How to use
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*" "*" ] }
Why not @types
?
To maintain the package by myself without waiting for external reviews.
Why is my fancy API still not available here?
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.
Is it fully automated?
Not yet. A small part of things still needs manual modification, which is done by files in inputfiles/
directory.
Build Instructions
To get things setup:
npm i
To generate the
.d.ts
filesnpm run build && npm run baseline-accept
To test:
npm test
Metadata
- Apache-2.0
- Whatever
- Kagami Sascha Rosylight
- released 6/18/2021