Go back

Modern types for the web ๐Ÿ’ก

modern-web-types adds TypeScript types for web APIs implemented in at least one browser engine.

Modern types for the web ๐Ÿ’ก

If you build applications on the cutting edge of web technology, you have surely run into TypeScript complaining about new APIs. That happens because the official DOM types include only APIs implemented in at least two browser engines.

To address this problem, Philip Walton created modern-web-types, a replacement for the standard types that lowers the threshold to one engine.

Under the hood, it uses the same generator (TypeScript-DOM-lib-generator) and W3C specifications as the official types, but lowers the bar: you get hundreds of new interfaces, globals and fields for features already available in at least one stable browser (for example, Chrome-first APIs such as View Transitions or fetchLater()).

Install it as an alias for TypeScript:

npm install --save-dev @typescript/lib-dom@npm:modern-web-types

Read the full article

Copied