`ReadableStream.pipeThrough` should be generic on `transform` argument and return real type of `ReadableStream`
Sorry if here is not the place to discuss individual API design.
Currently pipeThrough is defined as
https://github.com/microsoft/TypeScript-DOM-lib-generator/blob/11d922f302743cb3fcee9ab59b03d40074a2965c/baselines/dom.generated.d.ts#L11137
It always returns a ReadableStream<T>.
However according to spec it will return transform.readable
The
pipeThrough(transform, options)method steps are:[...]
- Return transform["
readable"].https://streams.spec.whatwg.org/#rs-pipe-through
And ReadableStream can be extended
class ReadableFileStream extends ReadableStream { constructor(filename) { super({ ... use filename to hook up underlying source here ... }); } }The latter [code above] is especially useful if you want to add more methods to each instance, or want to provide a namespace to hang static methods off of, or something.
https://github.com/whatwg/streams/issues/160#issuecomment-50029977
So now we will lost the real type of the ReadableStream.
Should it be override to
pipeThrough<T extends ReadableWritablePair<any, R>>(transform: T, options?: StreamPipeOptions): T["readable"];
Or we need to change IDL first?
Sounds like a good idea to me.