-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Description
A significant number of ECMAScript / web standards features that have recently standardized (like Iterator.concat) are still missing from the TypeScript standard library. There are ECMAScript proposals (like Iterator.zip) that are supported by modern browsers but still lack corresponding type definitions. Finally, many projects intentionally target older TypeScript versions with old standard library types.
I am working on types for the core-js polyfill library, which is used on most websites, so it makes a lot of sense to add type definitions for it. While doing this work, I have encountered some significant issues:
-
Some DOM types, for example
URL, are declared as ambient variable declarations with type literals inlib.dom.d.ts. This approach does not allow declaration merging. Possible solution: define them via interfaces (like in ECMAScript types) to allow declaration merging. -
The use of getters/setters. For example,
ArrayBufferdefines the detached property via a getter. This makes it impossible to create a compatible polyfill type for different targets. Similar issues often cause conflicts between different type libraries. In most similar cases, accessors are declared as readonly properties, and this does not cause any problems.
If there were some mechanism for conditional type usage, it could make the standard types more polyfills‑friendly.