microsoft / microsoft/TypeScript
Make standard library types more polyfills‑friendly
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
A significant number of ECMAScript / web standards features that have recently standardized (like [`Iterator.concat`](https://github.com/tc39/proposal-iterator-sequencing)) are still missing from the TypeScript standard library. There are ECMAScript proposals (like [`Iterator.zip`](https://github.com/tc39/proposal-joint-iteration)) 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](https://github.com/zloirock/core-js), 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 in `lib.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, [`ArrayBuffer` defines the detached property via a getter](https://github.com/microsoft/TypeScript/blob/3fc1f264de2aacae0c008eb4295e66833ade36d9/src/lib/es2024.arraybuffer.d.ts#L28). 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the ambient declarations in lib.dom.d.ts and the ArrayBuffer accessor in src/lib/es2024.arraybuffer.d.ts, alongside the linked core-js and ECMAScript proposal context. Done would require an agreed mechanism that makes standard-library types compatible with polyfills and older TypeScript library targets, plus corresponding library changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100