node
node copied to clipboard
Incompatible ReadableStream TypeScript types
Version
v20.12.1
Platform
Darwin arm64
Subsystem
No response
What steps will reproduce the bug?
- Install the
@types/nodetype definition package - Create a response object and store it's body as a stream, and try to provide it as the input of the
Readable.fromWebmethod.
import { Readable } from 'stream';
const stream = new Response('hello').body!;
Readable.fromWeb(stream);
- You will get an error message saying that the type are incompatible.
Argument of type 'ReadableStream<Uint8Array>' is not assignable to parameter of type 'ReadableStream<any>'.
Type 'ReadableStream<Uint8Array>' is missing the following properties from type 'ReadableStream<any>': values, [Symbol.asyncIterator]
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
The fromWeb function should use the same type definition as the global ReadableStream.
What do you see instead?
An type error:
Argument of type 'ReadableStream<Uint8Array>' is not assignable to parameter of type 'ReadableStream<any>'.
Type 'ReadableStream<Uint8Array>' is missing the following properties from type 'ReadableStream<any>': values, [Symbol.asyncIterator]
Additional information
The issue coming from the fact that the globalThis.ReadableStream<Uint8Array> and the ReadableStream definiton in node:stream/web is incompatible.