socketio / engine.io-parser

fix(typescript): properly import the TransformStream type
When compiling with TypeScript with module set to "node16" and moduleResolution to "node16", the following error would be thrown: > 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 This is because the TransformStream object is not exposed in the global scope in the `@types/node` package, even though it is since Node.js `v18.0.0`. Reference: https://nodejs.org/api/webstreams.html#class-transformstream Note: we only import the TransformStream type (not value) because it isn't defined on older Node.js versions. Related: - https://github.com/socketio/engine.io-parser/issues/136 - https://github.com/socketio/socket.io-client/issues/1606
Damien Arrachequesne Damien Arrachequesne committed on Feb 5, 2024, 07:27 AM
Showing 2 changed files +11 additions -6 deletions
Browse files at this commit โ†’