Skip to content

Commit 8e03af6

Browse files
authored
feat: update @types/node to v22 (discordjs#10926)
1 parent 9708717 commit 8e03af6

File tree

7 files changed

+17
-215
lines changed

7 files changed

+17
-215
lines changed

packages/rest/__tests__/RequestHandler.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ let serverOutage = true;
4747
let unexpected429 = true;
4848
let unexpected429cf = true;
4949
const sublimitIntervals: {
50-
reset: NodeJS.Timer | null;
51-
retry: NodeJS.Timer | null;
50+
reset: NodeJS.Timeout | null;
51+
retry: NodeJS.Timeout | null;
5252
} = {
5353
reset: null,
5454
retry: null,

packages/rest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"@discordjs/api-extractor": "workspace:^",
9999
"@discordjs/scripts": "workspace:^",
100100
"@favware/cliff-jumper": "^4.1.0",
101-
"@types/node": "18.17.9",
101+
"@types/node": "^22.15.2",
102102
"@vitest/coverage-v8": "^3.1.1",
103103
"cross-env": "^7.0.3",
104104
"esbuild-plugin-version-injector": "^1.2.1",

packages/rest/src/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import { Blob } from 'node:buffer';
21
import { shouldUseGlobalFetchAndWebSocket } from '@discordjs/util';
3-
import { FormData } from 'undici';
42
import { setDefaultStrategy } from './environment.js';
53
import { makeRequest } from './strategies/undiciRequest.js';
64

7-
// TODO(ckohen): remove once node engine req is bumped to > v18
8-
(globalThis as any).FormData ??= FormData;
9-
globalThis.Blob ??= Blob;
10-
11-
setDefaultStrategy(shouldUseGlobalFetchAndWebSocket() ? fetch : makeRequest);
5+
// This cast is needed because of a mismatch between the version of undici-types provided by @types/node and undici
6+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
7+
setDefaultStrategy(shouldUseGlobalFetchAndWebSocket() ? (fetch as typeof import('undici').fetch) : makeRequest);
128

139
export * from './shared.js';

packages/rest/src/lib/REST.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ export class REST extends AsyncEventEmitter<RestEvents> {
7070

7171
#token: string | null = null;
7272

73-
private hashTimer!: NodeJS.Timer | number;
73+
private hashTimer!: NodeJS.Timeout | number;
7474

75-
private handlerTimer!: NodeJS.Timer | number;
75+
private handlerTimer!: NodeJS.Timeout | number;
7676

7777
public readonly options: RESTOptions;
7878

packages/rest/src/lib/global/fetch.d.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/rest/src/web.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { setDefaultStrategy } from './environment.js';
22

3-
setDefaultStrategy(fetch);
3+
// This cast is needed because of a mismatch between the version of undici-types provided by @types/node and undici
4+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
5+
setDefaultStrategy(fetch as typeof import('undici').fetch);
46

57
export * from './shared.js';

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)