Skip to content

Commit f9cb983

Browse files
fix(engine.io-parser): do not expose the TransformStream type
The previous commit [1] tried to work around the fact that 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`. Unfortunately, it created two new issues: - using an older `@types/node` version (before v16) would fail with: > error TS2307: Cannot find module 'node:stream/web' or its corresponding type declarations. Related: #5064 (comment) - browser-only environments would somehow include the node types, leading to conflicts like the return value of the setTimeout() method Related: - #5064 (comment) - #5065 [1]: socketio/engine.io-parser@0305b4a
1 parent 04033b2 commit f9cb983

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

packages/engine.io-parser/lib/index.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import {
77
BinaryType,
88
ERROR_PACKET,
99
} from "./commons.js";
10-
// we can't import TransformStream as a value because it was added in Node.js v16.5.0, so it would break on older Node.js versions
11-
// reference: https://nodejs.org/api/webstreams.html#class-transformstream
12-
import type { TransformStream } from "node:stream/web";
1310

1411
const SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
1512

@@ -49,8 +46,7 @@ const decodePayload = (
4946
return packets;
5047
};
5148

52-
export function createPacketEncoderStream() {
53-
// @ts-expect-error
49+
export function createPacketEncoderStream(): any {
5450
return new TransformStream({
5551
transform(packet: Packet, controller) {
5652
encodePacketToBinary(packet, (encodedPacket) => {
@@ -117,7 +113,7 @@ const enum State {
117113
export function createPacketDecoderStream(
118114
maxPayload: number,
119115
binaryType: BinaryType,
120-
) {
116+
): any {
121117
if (!TEXT_DECODER) {
122118
TEXT_DECODER = new TextDecoder();
123119
}
@@ -126,7 +122,6 @@ export function createPacketDecoderStream(
126122
let expectedLength = -1;
127123
let isBinary = false;
128124

129-
// @ts-expect-error
130125
return new TransformStream({
131126
transform(chunk: Uint8Array, controller) {
132127
chunks.push(chunk);

0 commit comments

Comments
 (0)