Re: [whatwg/webidl] Add `async iterable<T>` type to WebIDL (PR #1397)

> 3\. As with `sequence<T>`, primitives like strings, even if they have `@@iterator` on their prototype, are not considered for `async iterator<T>` overloads, and are also not valid `async iterator<T>` values. `async iterator<T>` requires values are `Type(V) == Object`, in addition to having either `@@iterator` or `@@asyncIterator`.

This would technically be a breaking change for `ReadableStream.from()`, since we currently do accept strings (see [this test](https://github.com/web-platform-tests/wpt/blob/3fd901dba4d461afda4cf9b692f8bd99fb05f4e1/streams/readable-streams/from.any.js#L21-L24)).

That said, I wrote that test more as a sanity check, so I don't expect much usage in the wild. We can consider making `ReadableStream.from()` throw on strings, or we could change its signature to accept `async iterable<any> or string` instead.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/pull/1397#issuecomment-2020010833
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/pull/1397/c2020010833@github.com>

Received on Tuesday, 26 March 2024 10:06:28 UTC