2

I'm trying to build my socket.io code which used to build well, but now I don't know what changes caused the project build to give an error. Apparently, TransformStream, one of the built-in libraries of node, cannot be loaded in Typescript

node_modules/engine.io-parser/build/esm/index.d.ts:6:54 - error TS2304: Cannot find name 'TransformStream'.

6 export declare function createPacketEncoderStream(): TransformStream<Packet, any>;
                                                       ~~~~~~~~~~~~~~~

node_modules/engine.io-parser/build/esm/index.d.ts:7:96 - error TS2304: Cannot find name 'TransformStream'.

7 export declare function createPacketDecoderStream(maxPayload: number, binaryType: BinaryType): TransformStream<Uint8Array, any>;
                                                                                                 ~~~~~~~~~~~~~~~

If I put the following line in the part

node_modules/engine.io-parser/build/esm/index.d.ts:6:54

If I enter it, the error will be fixed, but this is not a correct way.

import { TransformStream } from "stream/web";

I also tried node in "types" tsconfig.json, but it didn't help

1
  • What's the version of typescript according to package.json? Commented Aug 4, 2023 at 16:53

4 Answers 4

6

Downgrading it fixed the issues for me

npm i [email protected]
Sign up to request clarification or add additional context in comments.

Comments

4

I had run into same issue. I've found that the issue is with changes done in [email protected] and above.

https://github.com/socketio/engine.io-parser/compare/5.1.0...5.2.0

Seems they introduced TransformStream there. For now I've moved back to fixed [email protected] and set resolutions to [email protected]

// package.json
    ....
    "resolutions": {
        "engine.io": "6.5.1"
    }

1 Comment

Related to this bug in engine.io github.com/socketio/engine.io-parser/issues/136 and this pull request in DefinitelyTyped: github.com/DefinitelyTyped/DefinitelyTyped/pull/66710
1

I ran into the same issue after upgrading socketio and typescript to @latest. I had to add "dom" to the lib array in tsconfig.json so that typescript includes the dom library files in the compilation.

// tsconfig.json
....
"lib": [
    ....
    "dom",
]

Comments

1

this worked for me in the tsconfig add it like this "lib": ["ESNext", "DOM"],

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.