microsoft / TypeScript-DOM-lib-generator

Tool for generating dom related TypeScript and JavaScript library files
Apache License 2.0
608 stars 418 forks source link

Q: Why are lib.dom and iterable separate? #1756

Closed MKRhere closed 1 month ago

MKRhere commented 1 month ago

For my own reasons, I have a script that converts ambient types into being exports. Naturally, the separation of iterables causes an issue with my approach.

At first, I thought the separation is because of old browsers where iterable versions of DOM constructs aren't available yet (IE?). But that opens up two big concerns:

  1. The rest of the DOM types are being updated anyway, which means there are plenty of methods and objects in the types that are incompatible with or don't exist in IE.
  2. lib.dom.d.ts from @types/web references iterable.d.ts anyway, which means there is actually no way to have DOM types without iterables.

Since my reasoning doesn't add up, is there an official reason for this separation? If there isn't a convincing reason (maybe there was a reason, but is no longer valid), would it be possible to merge them?

saschanaz commented 1 month ago

The main reason is that TypeScript still supports target: es5 and lib.dom needs to be compatible with it.

@types/web has the reference because it assumes es2015+ use should be the vast majority, but still we can't just throw es5 compatibility away for bundled types in the typescript compiler.

MKRhere commented 1 month ago

I understand, that makes sense. I'll work around it; thanks.