@types/node 22.5.1 → 22.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node/README.md +1 -1
- node/buffer.d.ts +17 -10
- node/globals.d.ts +93 -8
- node/http.d.ts +5 -5
- node/http2.d.ts +254 -77
- node/https.d.ts +18 -14
- node/package.json +2 -2
- node/stream/web.d.ts +262 -23
- node/test.d.ts +21 -12
node/README.md
CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
9
9
|
|
10
10
|
### Additional Details
|
11
|
-
* Last updated: Wed,
|
11
|
+
* Last updated: Wed, 04 Sep 2024 00:28:08 GMT
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
13
13
|
|
14
14
|
# Credits
|
node/buffer.d.ts
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
// If lib.dom.d.ts or lib.webworker.d.ts is loaded, then use the global types.
|
2
|
+
// Otherwise, use the types from node.
|
3
|
+
type _Blob = typeof globalThis extends { onmessage: any; Blob: any } ? {} : import("buffer").Blob;
|
4
|
+
type _File = typeof globalThis extends { onmessage: any; File: any } ? {} : import("buffer").File;
|
5
|
+
|
1
6
|
/**
|
2
7
|
* `Buffer` objects are used to represent a fixed-length sequence of bytes. Many
|
3
8
|
* Node.js APIs support `Buffer`s.
|
@@ -232,10 +237,7 @@ declare module "buffer" {
|
|
232
237
|
}
|
233
238
|
export import atob = globalThis.atob;
|
234
239
|
export import btoa = globalThis.btoa;
|
235
|
-
|
236
|
-
// This conditional type will be the existing global Blob in a browser, or
|
237
|
-
// the copy below in a Node environment.
|
238
|
-
type __Blob = typeof globalThis extends { onmessage: any; Blob: any } ? {} : NodeBlob;
|
240
|
+
|
239
241
|
global {
|
240
242
|
namespace NodeJS {
|
241
243
|
export { BufferEncoding };
|
@@ -2275,17 +2277,22 @@ declare module "buffer" {
|
|
2275
2277
|
* @param data An ASCII (Latin1) string.
|
2276
2278
|
*/
|
2277
2279
|
function btoa(data: string): string;
|
2278
|
-
interface Blob extends
|
2280
|
+
interface Blob extends _Blob {}
|
2279
2281
|
/**
|
2280
2282
|
* `Blob` class is a global reference for `require('node:buffer').Blob`
|
2281
2283
|
* https://nodejs.org/api/buffer.html#class-blob
|
2282
2284
|
* @since v18.0.0
|
2283
2285
|
*/
|
2284
|
-
var Blob: typeof globalThis extends {
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2286
|
+
var Blob: typeof globalThis extends { onmessage: any; Blob: infer T } ? T
|
2287
|
+
: typeof import("buffer").Blob;
|
2288
|
+
interface File extends _File {}
|
2289
|
+
/**
|
2290
|
+
* `File` class is a global reference for `require('node:buffer').File`
|
2291
|
+
* https://nodejs.org/api/buffer.html#class-file
|
2292
|
+
* @since v20.0.0
|
2293
|
+
*/
|
2294
|
+
var File: typeof globalThis extends { onmessage: any; File: infer T } ? T
|
2295
|
+
: typeof import("buffer").File;
|
2289
2296
|
}
|
2290
2297
|
}
|
2291
2298
|
declare module "node:buffer" {
|
node/globals.d.ts
CHANGED
@@ -12,7 +12,6 @@ type _RequestInit = typeof globalThis extends { onmessage: any } ? {}
|
|
12
12
|
: import("undici-types").RequestInit;
|
13
13
|
type _ResponseInit = typeof globalThis extends { onmessage: any } ? {}
|
14
14
|
: import("undici-types").ResponseInit;
|
15
|
-
type _File = typeof globalThis extends { onmessage: any } ? {} : import("node:buffer").File;
|
16
15
|
type _WebSocket = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").WebSocket;
|
17
16
|
type _EventSource = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").EventSource;
|
18
17
|
// #endregion Fetch and friends
|
@@ -60,6 +59,76 @@ type _Storage = typeof globalThis extends { onabort: any } ? {} : {
|
|
60
59
|
[key: string]: any;
|
61
60
|
};
|
62
61
|
|
62
|
+
// #region DOMException
|
63
|
+
type _DOMException = typeof globalThis extends { onmessage: any } ? {} : NodeDOMException;
|
64
|
+
interface NodeDOMException extends Error {
|
65
|
+
/**
|
66
|
+
* @deprecated
|
67
|
+
*
|
68
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
|
69
|
+
*/
|
70
|
+
readonly code: number;
|
71
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) */
|
72
|
+
readonly message: string;
|
73
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) */
|
74
|
+
readonly name: string;
|
75
|
+
readonly INDEX_SIZE_ERR: 1;
|
76
|
+
readonly DOMSTRING_SIZE_ERR: 2;
|
77
|
+
readonly HIERARCHY_REQUEST_ERR: 3;
|
78
|
+
readonly WRONG_DOCUMENT_ERR: 4;
|
79
|
+
readonly INVALID_CHARACTER_ERR: 5;
|
80
|
+
readonly NO_DATA_ALLOWED_ERR: 6;
|
81
|
+
readonly NO_MODIFICATION_ALLOWED_ERR: 7;
|
82
|
+
readonly NOT_FOUND_ERR: 8;
|
83
|
+
readonly NOT_SUPPORTED_ERR: 9;
|
84
|
+
readonly INUSE_ATTRIBUTE_ERR: 10;
|
85
|
+
readonly INVALID_STATE_ERR: 11;
|
86
|
+
readonly SYNTAX_ERR: 12;
|
87
|
+
readonly INVALID_MODIFICATION_ERR: 13;
|
88
|
+
readonly NAMESPACE_ERR: 14;
|
89
|
+
readonly INVALID_ACCESS_ERR: 15;
|
90
|
+
readonly VALIDATION_ERR: 16;
|
91
|
+
readonly TYPE_MISMATCH_ERR: 17;
|
92
|
+
readonly SECURITY_ERR: 18;
|
93
|
+
readonly NETWORK_ERR: 19;
|
94
|
+
readonly ABORT_ERR: 20;
|
95
|
+
readonly URL_MISMATCH_ERR: 21;
|
96
|
+
readonly QUOTA_EXCEEDED_ERR: 22;
|
97
|
+
readonly TIMEOUT_ERR: 23;
|
98
|
+
readonly INVALID_NODE_TYPE_ERR: 24;
|
99
|
+
readonly DATA_CLONE_ERR: 25;
|
100
|
+
}
|
101
|
+
interface NodeDOMExceptionConstructor {
|
102
|
+
prototype: DOMException;
|
103
|
+
new(message?: string, nameOrOptions?: string | { name?: string; cause?: unknown }): DOMException;
|
104
|
+
readonly INDEX_SIZE_ERR: 1;
|
105
|
+
readonly DOMSTRING_SIZE_ERR: 2;
|
106
|
+
readonly HIERARCHY_REQUEST_ERR: 3;
|
107
|
+
readonly WRONG_DOCUMENT_ERR: 4;
|
108
|
+
readonly INVALID_CHARACTER_ERR: 5;
|
109
|
+
readonly NO_DATA_ALLOWED_ERR: 6;
|
110
|
+
readonly NO_MODIFICATION_ALLOWED_ERR: 7;
|
111
|
+
readonly NOT_FOUND_ERR: 8;
|
112
|
+
readonly NOT_SUPPORTED_ERR: 9;
|
113
|
+
readonly INUSE_ATTRIBUTE_ERR: 10;
|
114
|
+
readonly INVALID_STATE_ERR: 11;
|
115
|
+
readonly SYNTAX_ERR: 12;
|
116
|
+
readonly INVALID_MODIFICATION_ERR: 13;
|
117
|
+
readonly NAMESPACE_ERR: 14;
|
118
|
+
readonly INVALID_ACCESS_ERR: 15;
|
119
|
+
readonly VALIDATION_ERR: 16;
|
120
|
+
readonly TYPE_MISMATCH_ERR: 17;
|
121
|
+
readonly SECURITY_ERR: 18;
|
122
|
+
readonly NETWORK_ERR: 19;
|
123
|
+
readonly ABORT_ERR: 20;
|
124
|
+
readonly URL_MISMATCH_ERR: 21;
|
125
|
+
readonly QUOTA_EXCEEDED_ERR: 22;
|
126
|
+
readonly TIMEOUT_ERR: 23;
|
127
|
+
readonly INVALID_NODE_TYPE_ERR: 24;
|
128
|
+
readonly DATA_CLONE_ERR: 25;
|
129
|
+
}
|
130
|
+
// #endregion DOMException
|
131
|
+
|
63
132
|
declare global {
|
64
133
|
// Declare "static" methods in Error
|
65
134
|
interface ErrorConstructor {
|
@@ -237,6 +306,24 @@ declare global {
|
|
237
306
|
transfer?: { transfer: ReadonlyArray<import("worker_threads").TransferListItem> },
|
238
307
|
): T;
|
239
308
|
|
309
|
+
// #region DOMException
|
310
|
+
/**
|
311
|
+
* @since v17.0.0
|
312
|
+
* An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API.
|
313
|
+
*
|
314
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
|
315
|
+
*/
|
316
|
+
interface DOMException extends _DOMException {}
|
317
|
+
|
318
|
+
/**
|
319
|
+
* @since v17.0.0
|
320
|
+
*
|
321
|
+
* The WHATWG `DOMException` class. See [DOMException](https://developer.mozilla.org/docs/Web/API/DOMException) for more details.
|
322
|
+
*/
|
323
|
+
var DOMException: typeof globalThis extends { onmessage: any; DOMException: infer T } ? T
|
324
|
+
: NodeDOMExceptionConstructor;
|
325
|
+
// #endregion DOMException
|
326
|
+
|
240
327
|
/*----------------------------------------------*
|
241
328
|
* *
|
242
329
|
* GLOBAL INTERFACES *
|
@@ -484,19 +571,15 @@ declare global {
|
|
484
571
|
: typeof import("undici-types").Headers;
|
485
572
|
|
486
573
|
interface MessageEvent extends _MessageEvent {}
|
574
|
+
/**
|
575
|
+
* @since v15.0.0
|
576
|
+
*/
|
487
577
|
var MessageEvent: typeof globalThis extends {
|
488
578
|
onmessage: any;
|
489
579
|
MessageEvent: infer T;
|
490
580
|
} ? T
|
491
581
|
: typeof import("undici-types").MessageEvent;
|
492
582
|
|
493
|
-
interface File extends _File {}
|
494
|
-
var File: typeof globalThis extends {
|
495
|
-
onmessage: any;
|
496
|
-
File: infer T;
|
497
|
-
} ? T
|
498
|
-
: typeof import("node:buffer").File;
|
499
|
-
|
500
583
|
interface WebSocket extends _WebSocket {}
|
501
584
|
var WebSocket: typeof globalThis extends { onmessage: any; WebSocket: infer T } ? T
|
502
585
|
: typeof import("undici-types").WebSocket;
|
@@ -504,6 +587,8 @@ declare global {
|
|
504
587
|
interface EventSource extends _EventSource {}
|
505
588
|
/**
|
506
589
|
* Only available through the [--experimental-eventsource](https://nodejs.org/api/cli.html#--experimental-eventsource) flag.
|
590
|
+
*
|
591
|
+
* @since v22.3.0
|
507
592
|
*/
|
508
593
|
var EventSource: typeof globalThis extends { onmessage: any; EventSource: infer T } ? T
|
509
594
|
: typeof import("undici-types").EventSource;
|
node/http.d.ts
CHANGED
@@ -231,7 +231,7 @@ declare module "http" {
|
|
231
231
|
}
|
232
232
|
interface ServerOptions<
|
233
233
|
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
234
|
-
Response extends typeof ServerResponse = typeof ServerResponse
|
234
|
+
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
|
235
235
|
> {
|
236
236
|
/**
|
237
237
|
* Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`.
|
@@ -315,14 +315,14 @@ declare module "http" {
|
|
315
315
|
}
|
316
316
|
type RequestListener<
|
317
317
|
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
318
|
-
Response extends typeof ServerResponse = typeof ServerResponse
|
318
|
+
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
|
319
319
|
> = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
|
320
320
|
/**
|
321
321
|
* @since v0.1.17
|
322
322
|
*/
|
323
323
|
class Server<
|
324
324
|
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
325
|
-
Response extends typeof ServerResponse = typeof ServerResponse
|
325
|
+
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
|
326
326
|
> extends NetServer {
|
327
327
|
constructor(requestListener?: RequestListener<Request, Response>);
|
328
328
|
constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
|
@@ -1553,11 +1553,11 @@ declare module "http" {
|
|
1553
1553
|
*/
|
1554
1554
|
function createServer<
|
1555
1555
|
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
1556
|
-
Response extends typeof ServerResponse = typeof ServerResponse
|
1556
|
+
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
|
1557
1557
|
>(requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
|
1558
1558
|
function createServer<
|
1559
1559
|
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
1560
|
-
Response extends typeof ServerResponse = typeof ServerResponse
|
1560
|
+
Response extends typeof ServerResponse<InstanceType<Request>> = typeof ServerResponse<InstanceType<Request>>,
|
1561
1561
|
>(
|
1562
1562
|
options: ServerOptions<Request, Response>,
|
1563
1563
|
requestListener?: RequestListener<Request, Response>,
|