engine.io-parser icon indicating copy to clipboard operation
engine.io-parser copied to clipboard

Cannot find name 'TransformStream' after updating to v5.2.0

Open Julien-Marcou opened this issue 2 years ago • 21 comments
trafficstars

Since I updated socket.io from the v4.7.1 to the v4.7.2 (and so engine.io-parser from the v5.1.0 to the v5.2.1), I'm getting the following errors while building my projects:

node_modules/engine.io-parser/build/cjs/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/cjs/index.d.ts:7:96 - error TS2304: Cannot find name 'TransformStream'.
7 export declare function createPacketDecoderStream(maxPayload: number, binaryType: BinaryType): TransformStream<Uint8Array, any>;
                                                                                                 ~~~~~~~~~~~~~~~

Found 2 errors in the same file, starting at: node_modules/engine.io-parser/build/cjs/index.d.ts:6

Funnily, I'm only getting this error when compiling using tsc but not when compiling using esbuild.

npx tsc -> error npx esbuild src/index.ts --platform=node -> ok

Here is my tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist",
    "strict": true,
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node16",
    "importHelpers": true,
    "target": "es2022",
    "module": "node16",
    "lib": [
      "es2022"
    ]
  },
  "include": [
    "src/**/*.ts"
  ]
}

Reading nodejs's documentation, when using TransformStream, it looks like they are importing it with

import { TransformStream } from 'node:stream/web';

which is not the case for engine.io-parser, so maybe that's the problem.

Julien-Marcou avatar Aug 27 '23 19:08 Julien-Marcou