Skip to content

ReadableStream is not a subtype of AsyncIteratorΒ #57874

@spencerwilson

Description

@spencerwilson

πŸ”Ž 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions