[heycam/webidl] Add typed ReadableStream<type> and WritableStream<type> (#951)

The [WebTransport spec](https://w3c.github.io/webtransport/#idl-index) is full of WebIDL with comments like this one (third line):
```webidl
interface mixin UnidirectionalStreamsTransport {
  Promise<SendStream> createUnidirectionalStream(optional SendStreamParameters parameters = {});
  /* a ReadableStream of ReceiveStream objects */
  readonly attribute ReadableStream incomingUnidirectionalStreams;
};
```
Without this comment, it'd be hard to reason about what `incomingUnidirectionalStreams` gives you.

I think `ReadableStream` and `WritableStream` deserve the same treatment as `Promise` here:
```webidl
interface mixin UnidirectionalStreamsTransport {
  Promise<SendStream> createUnidirectionalStream(optional SendStreamParameters parameters = {});
  readonly attribute ReadableStream<ReceiveStream> incomingUnidirectionalStreams;
};
```

This would follow a tradition of making I/O types part of an API's code signature, helping readers reason about call sites.


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/issues/951

Received on Tuesday, 26 January 2021 20:14:16 UTC