microsoft / TypeScript-DOM-lib-generator

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

`ReadableStream` should be async-iterable #1677

Closed kraenhansen closed 3 months ago

kraenhansen commented 5 months ago

As per https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#async_iteration and https://streams.spec.whatwg.org/#rs-asynciterator

ReadableStream implements the async iterable protocol. This enables asynchronous iteration over the chunks in a stream using the for await...of syntax.

The current types declare no Symbol.asyncIterator nor extends AsyncIterator:

https://github.com/microsoft/TypeScript-DOM-lib-generator/blob/f4e507c3d0ba16fde16026d9265c201fecdb6538/baselines/dom.generated.d.ts#L18604-L18631

I'd expect a Symbol.asyncIterator member on the ReadableStream.

I noticed that it does seem like an iterator is added to the input file: https://github.com/microsoft/TypeScript-DOM-lib-generator/blob/f4e507c3d0ba16fde16026d9265c201fecdb6538/inputfiles/overridingTypes.jsonc#L2629-L2635