Skip to content

Commit 8bead0f

Browse files
chore: upgrade to TypeScript 6
Notes: - some packages still use "strict: false" and will be migrated later - tsd (https://github.com/tsdjs/tsd) has not been upgraded yet Reference: microsoft/TypeScript#62508
1 parent d9bbbd4 commit 8bead0f

30 files changed

Lines changed: 92 additions & 51 deletions

File tree

‎package-lock.json‎

Lines changed: 22 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@types/debug": "^4.1.12",
3838
"@types/expect.js": "^0.3.32",
3939
"@types/mocha": "^10.0.7",
40-
"@types/node": "18.15.3",
40+
"@types/node": "^24.13.2",
4141
"@types/pg": "^8.6.0",
4242
"@types/sinonjs__fake-timers": "^8.1.5",
4343
"@wdio/cli": "^8.39.1",
@@ -77,7 +77,7 @@
7777
"ts-node": "^10.9.2",
7878
"tsd": "^0.31.1",
7979
"tsx": "~4.20.6",
80-
"typescript": "^5.5.3",
80+
"typescript": "^6.0.3",
8181
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.56.0",
8282
"wdio-geckodriver-service": "^5.0.2"
8383
}

‎packages/engine.io-client/lib/socket.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ export class SocketWithoutUpgrade extends Emitter<
342342
private _pingInterval: number = -1;
343343
private _pingTimeout: number = -1;
344344
private _maxPayload?: number = -1;
345-
private _pingTimeoutTimer: NodeJS.Timer;
345+
private _pingTimeoutTimer: NodeJS.Timeout;
346346
/**
347347
* The expiration timestamp of the {@link _pingTimeoutTimer} object is tracked, in case the timer is throttled and the
348348
* callback is not fired on time. This can happen for example when a laptop is suspended or when a phone is locked.

‎packages/engine.io-client/tsconfig.esm.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"compilerOptions": {
3+
"rootDir": "lib/",
34
"outDir": "build/esm/",
45
"target": "es2018",
56
"module": "esnext",
6-
"moduleResolution": "node",
7-
"declaration": true
7+
"declaration": true,
8+
"strict": false
89
},
910
"include": [
1011
"./lib/**/*"

‎packages/engine.io-client/tsconfig.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{
22
"compilerOptions": {
3+
"rootDir": "lib/",
34
"outDir": "build/cjs/",
45
"target": "es2018", // Node.js 10 (https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping)
56
"module": "commonjs",
67
"declaration": true,
7-
"esModuleInterop": true
8+
"esModuleInterop": true,
9+
"strict": false
810
},
911
"include": [
1012
"./lib/**/*"

‎packages/engine.io-parser/lib/decodePacket.browser.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const decodePacket = (
4040
};
4141
};
4242

43-
const decodeBase64Packet = (data, binaryType) => {
43+
const decodeBase64Packet = (data: string, binaryType?: BinaryType) => {
4444
if (withNativeArrayBuffer) {
4545
const decoded = decode(data);
4646
return mapBinary(decoded, binaryType);
@@ -49,7 +49,7 @@ const decodeBase64Packet = (data, binaryType) => {
4949
}
5050
};
5151

52-
const mapBinary = (data, binaryType) => {
52+
const mapBinary = (data: any, binaryType?: BinaryType) => {
5353
switch (binaryType) {
5454
case "blob":
5555
if (data instanceof Blob) {

‎packages/engine.io-parser/lib/encodePacket.browser.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const withNativeBlob =
77
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
88

99
// ArrayBuffer.isView method is not defined in IE10
10-
const isView = (obj) => {
10+
const isView = (obj: any) => {
1111
return typeof ArrayBuffer.isView === "function"
1212
? ArrayBuffer.isView(obj)
1313
: obj && obj.buffer instanceof ArrayBuffer;
@@ -60,7 +60,7 @@ function toArray(data: BufferSource) {
6060
}
6161
}
6262

63-
let TEXT_ENCODER;
63+
let TEXT_ENCODER: TextEncoder | undefined;
6464

6565
export function encodePacketToBinary(
6666
packet: Packet,

‎packages/engine.io-parser/lib/encodePacket.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export const encodePacket = (
1414
return callback(PACKET_TYPES[type] + (data || ""));
1515
};
1616

17-
const toBuffer = (data: BufferSource, forceBufferConversion: boolean) => {
17+
const toBuffer = (
18+
data: ArrayBuffer | ArrayBufferView,
19+
forceBufferConversion: boolean,
20+
) => {
1821
if (
1922
Buffer.isBuffer(data) ||
2023
(data instanceof Uint8Array && !forceBufferConversion)
@@ -27,7 +30,7 @@ const toBuffer = (data: BufferSource, forceBufferConversion: boolean) => {
2730
}
2831
};
2932

30-
let TEXT_ENCODER;
33+
let TEXT_ENCODER: TextEncoder | undefined;
3134

3235
export function encodePacketToBinary(
3336
packet: Packet,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ export function createPacketEncoderStream(): any {
7878
});
7979
}
8080

81-
let TEXT_DECODER;
81+
let TEXT_DECODER: TextDecoder | undefined;
8282

8383
function totalLength(chunks: Uint8Array[]) {
8484
return chunks.reduce((acc, chunk) => acc + chunk.length, 0);
8585
}
8686

8787
function concatChunks(chunks: Uint8Array[], size: number) {
8888
if (chunks[0].length === size) {
89-
return chunks.shift();
89+
return chunks.shift()!;
9090
}
9191
const buffer = new Uint8Array(size);
9292
let j = 0;
@@ -180,7 +180,7 @@ export function createPacketDecoderStream(
180180
const data = concatChunks(chunks, expectedLength);
181181
controller.enqueue(
182182
decodePacket(
183-
isBinary ? data : TEXT_DECODER.decode(data),
183+
isBinary ? data : TEXT_DECODER!.decode(data),
184184
binaryType,
185185
),
186186
);

‎packages/engine.io-parser/tsconfig.esm.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"compilerOptions": {
3+
"rootDir": "lib/",
34
"outDir": "build/esm/",
45
"target": "es2018",
56
"module": "esnext",
6-
"moduleResolution": "node",
7-
"declaration": true
7+
"declaration": true,
8+
"types": ["node"]
89
},
910
"include": [
1011
"./lib/**/*"

0 commit comments

Comments
 (0)