Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadableStream is not a subtype of AsyncIterator #57874

Closed
spencerwilson opened this issue Mar 21, 2024 · 4 comments
Closed

ReadableStream is not a subtype of AsyncIterator #57874

spencerwilson opened this issue Mar 21, 2024 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@spencerwilson
Copy link

spencerwilson commented Mar 21, 2024

πŸ”Ž Search Terms

  • ReadableStream

πŸ•— Version & Regression Information

I'm using 5.3.2.

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about ReadableStream/differences in environments

⏯ Playground Link

No response

πŸ’» Code

const rs: AsyncIterable<Uint8Array> = new ReadableStream<Uint8Array>();

πŸ™ Actual behavior

tsc reports the following error:

Property '[Symbol.asyncIterator]' is missing in type 'ReadableStream<Uint8Array>' but required in type 'AsyncIterable<Uint8Array>'.

That property should not have been missing in ReadableStream.

πŸ™‚ Expected behavior

No error, because the Streams WHATWG Living Standard documents that ReadableStream is an async iterable: https://streams.spec.whatwg.org/#rs-asynciterator

Additional information about the issue

Admittedly, this isn't widely supported. At time of writing, it may be that just 3 runtimes support it:

image

Live data: https://caniuse.com/mdn-api_readablestream_--asynciterator

Note: The browser-compat-data calls this feature "experimental", but I'm not sure what the basis for that is. See mdn/browser-compat-data#22676 h/t @fatcerberus for explaining this classification

@fatcerberus
Copy link

Kind of interesting that Node.js supports it since 16.5.0 (July 2021) but Chrome apparently doesn't support it at all, especially since both use V8...

Most likely it's marked experimental because it's only supported by one browser engine (Firefox). Node.js and Deno are not browsers.

@Jamesernator
Copy link

Kind of interesting that Node.js supports it since 16.5.0 (July 2021) but Chrome apparently doesn't support it at all

It will be available in the next version of Chrome.

@MartinJohns
Copy link
Contributor

Duplicate of microsoft/TypeScript-DOM-lib-generator#1677.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Mar 21, 2024
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

6 participants