Skip to content

[@types/node] ReadableStream type definition here is not compatible with TypeScript's #65542

Discussion options

You must be logged in to vote

The root cause of this problem is that typescript has removed the type definition that generates the async
iterator for ReadableStream
. They also did this because chromium has never implemented this functionality, but
Nodejs already implements this, so the type definition difference is caused.

My personal advice is as follows:

  1. if the code only runs in Nodejs, then do the type casting directly:
import { default as stream } from 'node:stream'.
import type { ReadableStream } from 'node:stream/web'.

const response = await fetch('xxx')
stream.Readable.fromWeb(response.body as ReadableStream<Uint8Array>)
  1. If the code needs to take into account the browser's runtime environment, you can add a…

Replies: 7 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@peterblazejewicz
Comment options

@suerta-git
Comment options

Comment options

You must be logged in to vote
1 reply
@wangzishi
Comment options

Comment options

You must be logged in to vote
1 reply
@wangzishi
Comment options

Comment options

You must be logged in to vote
2 replies
@suerta-git
Comment options

@TechQuery
Comment options

Answer selected by suerta-git
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pkg: node Discussions related to node
8 participants