@types/node 22.15.13 → 22.18.9

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.
Files changed (76) hide show
  1. node v22.18/README.md +15 -0
  2. node/assert.d.ts → node v22.18/assert.d.ts +19 -0
  3. node/buffer.d.ts → node v22.18/buffer.d.ts +6 -2
  4. node/child_process.d.ts → node v22.18/child_process.d.ts +26 -122
  5. node/compatibility/disposable.d.ts → node v22.18/compatibility/disposable.d.ts +0 -2
  6. node/compatibility/indexable.d.ts → node v22.18/compatibility/indexable.d.ts +0 -3
  7. node/compatibility/iterators.d.ts → node v22.18/compatibility/iterators.d.ts +0 -1
  8. node/crypto.d.ts → node v22.18/crypto.d.ts +17 -1
  9. node/diagnostics_channel.d.ts → node v22.18/diagnostics_channel.d.ts +18 -13
  10. node/dns/promises.d.ts → node v22.18/dns/promises.d.ts +36 -9
  11. node/dns.d.ts → node v22.18/dns.d.ts +73 -20
  12. node/events.d.ts → node v22.18/events.d.ts +79 -34
  13. node/fs/promises.d.ts → node v22.18/fs/promises.d.ts +57 -39
  14. node/fs.d.ts → node v22.18/fs.d.ts +98 -47
  15. node v22.18/globals.d.ts +172 -0
  16. node/http.d.ts → node v22.18/http.d.ts +72 -6
  17. node/http2.d.ts → node v22.18/http2.d.ts +81 -2
  18. node/https.d.ts → node v22.18/https.d.ts +5 -0
  19. node/index.d.ts → node v22.18/index.d.ts +7 -3
  20. node/inspector.d.ts → node v22.18/inspector.generated.d.ts +219 -10
  21. node/module.d.ts → node v22.18/module.d.ts +136 -17
  22. node/net.d.ts → node v22.18/net.d.ts +3 -3
  23. node/package.json → node v22.18/package.json +3 -83
  24. node/perf_hooks.d.ts → node v22.18/perf_hooks.d.ts +2 -2
  25. node/process.d.ts → node v22.18/process.d.ts +3 -4
  26. node/readline/promises.d.ts → node v22.18/readline/promises.d.ts +0 -1
  27. node/repl.d.ts → node v22.18/repl.d.ts +3 -5
  28. node/sqlite.d.ts → node v22.18/sqlite.d.ts +207 -0
  29. node/stream/web.d.ts → node v22.18/stream/web.d.ts +8 -0
  30. node/stream.d.ts → node v22.18/stream.d.ts +5 -10
  31. node v22.18/test.d.ts +2162 -0
  32. node/ts5.6/index.d.ts → node v22.18/ts5.6/index.d.ts +7 -3
  33. node/url.d.ts → node v22.18/url.d.ts +12 -3
  34. node/util.d.ts → node v22.18/util.d.ts +20 -5
  35. node/v8.d.ts → node v22.18/v8.d.ts +60 -30
  36. node/vm.d.ts → node v22.18/vm.d.ts +61 -8
  37. node v22.18/web-globals/abortcontroller.d.ts +34 -0
  38. node v22.18/web-globals/domexception.d.ts +68 -0
  39. node v22.18/web-globals/events.d.ts +97 -0
  40. node v22.18/web-globals/fetch.d.ts +46 -0
  41. node v22.18/web-globals/navigator.d.ts +22 -0
  42. node v22.18/web-globals/storage.d.ts +24 -0
  43. node/worker_threads.d.ts → node v22.18/worker_threads.d.ts +105 -74
  44. node/zlib.d.ts → node v22.18/zlib.d.ts +8 -2
  45. node/README.md +0 -15
  46. node/dom-events.d.ts +0 -124
  47. node/globals.d.ts +0 -371
  48. node/test.d.ts +0 -2280
  49. {node → node v22.18}/LICENSE +0 -0
  50. {node → node v22.18}/assert/strict.d.ts +0 -0
  51. node/async_hooks.d.ts → node v22.18/async_hooks.d.ts +1 -1
  52. {node → node v22.18}/buffer.buffer.d.ts +0 -0
  53. {node → node v22.18}/cluster.d.ts +0 -0
  54. {node → node v22.18}/compatibility/index.d.ts +0 -0
  55. {node → node v22.18}/console.d.ts +0 -0
  56. {node → node v22.18}/constants.d.ts +0 -0
  57. {node → node v22.18}/dgram.d.ts +0 -0
  58. {node → node v22.18}/domain.d.ts +0 -0
  59. {node → node v22.18}/globals.typedarray.d.ts +0 -0
  60. {node → node v22.18}/os.d.ts +0 -0
  61. {node → node v22.18}/path.d.ts +0 -0
  62. {node → node v22.18}/punycode.d.ts +0 -0
  63. {node → node v22.18}/querystring.d.ts +0 -0
  64. {node → node v22.18}/readline.d.ts +0 -0
  65. {node → node v22.18}/sea.d.ts +0 -0
  66. {node → node v22.18}/stream/consumers.d.ts +0 -0
  67. {node → node v22.18}/stream/promises.d.ts +0 -0
  68. {node → node v22.18}/string_decoder.d.ts +0 -0
  69. {node → node v22.18}/timers/promises.d.ts +0 -0
  70. {node → node v22.18}/timers.d.ts +0 -0
  71. {node → node v22.18}/tls.d.ts +0 -0
  72. {node → node v22.18}/trace_events.d.ts +0 -0
  73. {node → node v22.18}/ts5.6/buffer.buffer.d.ts +0 -0
  74. {node → node v22.18}/ts5.6/globals.typedarray.d.ts +0 -0
  75. {node → node v22.18}/tty.d.ts +0 -0
  76. {node → node v22.18}/wasi.d.ts +0 -0
@@ -198,7 +198,7 @@ declare module "fs" {
198
198
  * the `withFileTypes` option set to `true`, the resulting array is filled with `fs.Dirent` objects, rather than strings or `Buffer` s.
199
199
  * @since v10.10.0
200
200
  */
201
- export class Dirent {
201
+ export class Dirent<Name extends string | Buffer = string> {
202
202
  /**
203
203
  * Returns `true` if the `fs.Dirent` object describes a regular file.
204
204
  * @since v10.10.0
@@ -241,10 +241,10 @@ declare module "fs" {
241
241
  * value is determined by the `options.encoding` passed to {@link readdir} or {@link readdirSync}.
242
242
  * @since v10.10.0
243
243
  */
244
- name: string;
244
+ name: Name;
245
245
  /**
246
- * The base path that this `fs.Dirent` object refers to.
247
- * @since v20.12.0
246
+ * The path to the parent directory of the file this `fs.Dirent` object refers to.
247
+ * @since v20.12.0, v18.20.0
248
248
  */
249
249
  parentPath: string;
250
250
  /**
@@ -328,6 +328,20 @@ declare module "fs" {
328
328
  * @since v12.12.0
329
329
  */
330
330
  readSync(): Dirent | null;
331
+ /**
332
+ * Calls `dir.close()` if the directory handle is open, and returns a promise that
333
+ * fulfills when disposal is complete.
334
+ * @since v22.17.0
335
+ * @experimental
336
+ */
337
+ [Symbol.asyncDispose](): Promise<void>;
338
+ /**
339
+ * Calls `dir.closeSync()` if the directory handle is open, and returns
340
+ * `undefined`.
341
+ * @since v22.17.0
342
+ * @experimental
343
+ */
344
+ [Symbol.dispose](): void;
331
345
  }
332
346
  /**
333
347
  * Class: fs.StatWatcher
@@ -2040,6 +2054,20 @@ declare module "fs" {
2040
2054
  },
2041
2055
  callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void,
2042
2056
  ): void;
2057
+ /**
2058
+ * Asynchronous readdir(3) - read a directory.
2059
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2060
+ * @param options Must include `withFileTypes: true` and `encoding: 'buffer'`.
2061
+ */
2062
+ export function readdir(
2063
+ path: PathLike,
2064
+ options: {
2065
+ encoding: "buffer";
2066
+ withFileTypes: true;
2067
+ recursive?: boolean | undefined;
2068
+ },
2069
+ callback: (err: NodeJS.ErrnoException | null, files: Dirent<Buffer>[]) => void,
2070
+ ): void;
2043
2071
  export namespace readdir {
2044
2072
  /**
2045
2073
  * Asynchronous readdir(3) - read a directory.
@@ -2099,6 +2127,19 @@ declare module "fs" {
2099
2127
  recursive?: boolean | undefined;
2100
2128
  },
2101
2129
  ): Promise<Dirent[]>;
2130
+ /**
2131
+ * Asynchronous readdir(3) - read a directory.
2132
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2133
+ * @param options Must include `withFileTypes: true` and `encoding: 'buffer'`.
2134
+ */
2135
+ function __promisify__(
2136
+ path: PathLike,
2137
+ options: {
2138
+ encoding: "buffer";
2139
+ withFileTypes: true;
2140
+ recursive?: boolean | undefined;
2141
+ },
2142
+ ): Promise<Dirent<Buffer>[]>;
2102
2143
  }
2103
2144
  /**
2104
2145
  * Reads the contents of the directory.
@@ -2166,6 +2207,19 @@ declare module "fs" {
2166
2207
  recursive?: boolean | undefined;
2167
2208
  },
2168
2209
  ): Dirent[];
2210
+ /**
2211
+ * Synchronous readdir(3) - read a directory.
2212
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2213
+ * @param options Must include `withFileTypes: true` and `encoding: 'buffer'`.
2214
+ */
2215
+ export function readdirSync(
2216
+ path: PathLike,
2217
+ options: {
2218
+ encoding: "buffer";
2219
+ withFileTypes: true;
2220
+ recursive?: boolean | undefined;
2221
+ },
2222
+ ): Dirent<Buffer>[];
2169
2223
  /**
2170
2224
  * Closes the file descriptor. No arguments other than a possible exception are
2171
2225
  * given to the completion callback.
@@ -2616,7 +2670,7 @@ declare module "fs" {
2616
2670
  buffer: TBuffer,
2617
2671
  offset: number,
2618
2672
  length: number,
2619
- position: number | null,
2673
+ position: ReadPosition | null,
2620
2674
  ): Promise<{
2621
2675
  bytesRead: number;
2622
2676
  buffer: TBuffer;
@@ -3287,6 +3341,12 @@ declare module "fs" {
3287
3341
  persistent?: boolean | undefined;
3288
3342
  recursive?: boolean | undefined;
3289
3343
  }
3344
+ export interface WatchOptionsWithBufferEncoding extends WatchOptions {
3345
+ encoding: "buffer";
3346
+ }
3347
+ export interface WatchOptionsWithStringEncoding extends WatchOptions {
3348
+ encoding?: BufferEncoding | undefined;
3349
+ }
3290
3350
  export type WatchEventType = "rename" | "change";
3291
3351
  export type WatchListener<T> = (event: WatchEventType, filename: T | null) => void;
3292
3352
  export type StatsListener = (curr: Stats, prev: Stats) => void;
@@ -3313,44 +3373,20 @@ declare module "fs" {
3313
3373
  */
3314
3374
  export function watch(
3315
3375
  filename: PathLike,
3316
- options:
3317
- | (WatchOptions & {
3318
- encoding: "buffer";
3319
- })
3320
- | "buffer",
3321
- listener?: WatchListener<Buffer>,
3376
+ options?: WatchOptionsWithStringEncoding | BufferEncoding | null,
3377
+ listener?: WatchListener<string>,
3322
3378
  ): FSWatcher;
3323
- /**
3324
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3325
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3326
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
3327
- * If `encoding` is not supplied, the default of `'utf8'` is used.
3328
- * If `persistent` is not supplied, the default of `true` is used.
3329
- * If `recursive` is not supplied, the default of `false` is used.
3330
- */
3331
3379
  export function watch(
3332
3380
  filename: PathLike,
3333
- options?: WatchOptions | BufferEncoding | null,
3334
- listener?: WatchListener<string>,
3381
+ options: WatchOptionsWithBufferEncoding | "buffer",
3382
+ listener: WatchListener<Buffer>,
3335
3383
  ): FSWatcher;
3336
- /**
3337
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3338
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3339
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
3340
- * If `encoding` is not supplied, the default of `'utf8'` is used.
3341
- * If `persistent` is not supplied, the default of `true` is used.
3342
- * If `recursive` is not supplied, the default of `false` is used.
3343
- */
3344
3384
  export function watch(
3345
3385
  filename: PathLike,
3346
- options: WatchOptions | string,
3347
- listener?: WatchListener<string | Buffer>,
3386
+ options: WatchOptions | BufferEncoding | "buffer" | null,
3387
+ listener: WatchListener<string | Buffer>,
3348
3388
  ): FSWatcher;
3349
- /**
3350
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3351
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3352
- */
3353
- export function watch(filename: PathLike, listener?: WatchListener<string>): FSWatcher;
3389
+ export function watch(filename: PathLike, listener: WatchListener<string>): FSWatcher;
3354
3390
  /**
3355
3391
  * Test whether or not the given path exists by checking with the file system.
3356
3392
  * Then call the `callback` argument with either true or false:
@@ -4160,7 +4196,6 @@ declare module "fs" {
4160
4196
  * blob.stream();
4161
4197
  * ```
4162
4198
  * @since v19.8.0
4163
- * @experimental
4164
4199
  */
4165
4200
  export function openAsBlob(path: PathLike, options?: OpenAsBlobOptions): Promise<Blob>;
4166
4201
 
@@ -4321,7 +4356,7 @@ declare module "fs" {
4321
4356
  * Current working directory.
4322
4357
  * @default process.cwd()
4323
4358
  */
4324
- cwd?: string | undefined;
4359
+ cwd?: string | URL | undefined;
4325
4360
  /**
4326
4361
  * `true` if the glob should return paths as `Dirent`s, `false` otherwise.
4327
4362
  * @default false
@@ -4346,13 +4381,23 @@ declare module "fs" {
4346
4381
 
4347
4382
  /**
4348
4383
  * Retrieves the files matching the specified pattern.
4384
+ *
4385
+ * ```js
4386
+ * import { glob } from 'node:fs';
4387
+ *
4388
+ * glob('*.js', (err, matches) => {
4389
+ * if (err) throw err;
4390
+ * console.log(matches);
4391
+ * });
4392
+ * ```
4393
+ * @since v22.0.0
4349
4394
  */
4350
4395
  export function glob(
4351
- pattern: string | string[],
4396
+ pattern: string | readonly string[],
4352
4397
  callback: (err: NodeJS.ErrnoException | null, matches: string[]) => void,
4353
4398
  ): void;
4354
4399
  export function glob(
4355
- pattern: string | string[],
4400
+ pattern: string | readonly string[],
4356
4401
  options: GlobOptionsWithFileTypes,
4357
4402
  callback: (
4358
4403
  err: NodeJS.ErrnoException | null,
@@ -4360,7 +4405,7 @@ declare module "fs" {
4360
4405
  ) => void,
4361
4406
  ): void;
4362
4407
  export function glob(
4363
- pattern: string | string[],
4408
+ pattern: string | readonly string[],
4364
4409
  options: GlobOptionsWithoutFileTypes,
4365
4410
  callback: (
4366
4411
  err: NodeJS.ErrnoException | null,
@@ -4368,7 +4413,7 @@ declare module "fs" {
4368
4413
  ) => void,
4369
4414
  ): void;
4370
4415
  export function glob(
4371
- pattern: string | string[],
4416
+ pattern: string | readonly string[],
4372
4417
  options: GlobOptions,
4373
4418
  callback: (
4374
4419
  err: NodeJS.ErrnoException | null,
@@ -4376,19 +4421,25 @@ declare module "fs" {
4376
4421
  ) => void,
4377
4422
  ): void;
4378
4423
  /**
4379
- * Retrieves the files matching the specified pattern.
4424
+ * ```js
4425
+ * import { globSync } from 'node:fs';
4426
+ *
4427
+ * console.log(globSync('*.js'));
4428
+ * ```
4429
+ * @since v22.0.0
4430
+ * @returns paths of files that match the pattern.
4380
4431
  */
4381
- export function globSync(pattern: string | string[]): string[];
4432
+ export function globSync(pattern: string | readonly string[]): string[];
4382
4433
  export function globSync(
4383
- pattern: string | string[],
4434
+ pattern: string | readonly string[],
4384
4435
  options: GlobOptionsWithFileTypes,
4385
4436
  ): Dirent[];
4386
4437
  export function globSync(
4387
- pattern: string | string[],
4438
+ pattern: string | readonly string[],
4388
4439
  options: GlobOptionsWithoutFileTypes,
4389
4440
  ): string[];
4390
4441
  export function globSync(
4391
- pattern: string | string[],
4442
+ pattern: string | readonly string[],
4392
4443
  options: GlobOptions,
4393
4444
  ): Dirent[] | string[];
4394
4445
  }
@@ -0,0 +1,172 @@
1
+ declare var global: typeof globalThis;
2
+
3
+ declare var process: NodeJS.Process;
4
+ declare var console: Console;
5
+
6
+ interface ErrorConstructor {
7
+ /**
8
+ * Creates a `.stack` property on `targetObject`, which when accessed returns
9
+ * a string representing the location in the code at which
10
+ * `Error.captureStackTrace()` was called.
11
+ *
12
+ * ```js
13
+ * const myObject = {};
14
+ * Error.captureStackTrace(myObject);
15
+ * myObject.stack; // Similar to `new Error().stack`
16
+ * ```
17
+ *
18
+ * The first line of the trace will be prefixed with
19
+ * `${myObject.name}: ${myObject.message}`.
20
+ *
21
+ * The optional `constructorOpt` argument accepts a function. If given, all frames
22
+ * above `constructorOpt`, including `constructorOpt`, will be omitted from the
23
+ * generated stack trace.
24
+ *
25
+ * The `constructorOpt` argument is useful for hiding implementation
26
+ * details of error generation from the user. For instance:
27
+ *
28
+ * ```js
29
+ * function a() {
30
+ * b();
31
+ * }
32
+ *
33
+ * function b() {
34
+ * c();
35
+ * }
36
+ *
37
+ * function c() {
38
+ * // Create an error without stack trace to avoid calculating the stack trace twice.
39
+ * const { stackTraceLimit } = Error;
40
+ * Error.stackTraceLimit = 0;
41
+ * const error = new Error();
42
+ * Error.stackTraceLimit = stackTraceLimit;
43
+ *
44
+ * // Capture the stack trace above function b
45
+ * Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
46
+ * throw error;
47
+ * }
48
+ *
49
+ * a();
50
+ * ```
51
+ */
52
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
53
+ /**
54
+ * @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces
55
+ */
56
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
57
+ /**
58
+ * The `Error.stackTraceLimit` property specifies the number of stack frames
59
+ * collected by a stack trace (whether generated by `new Error().stack` or
60
+ * `Error.captureStackTrace(obj)`).
61
+ *
62
+ * The default value is `10` but may be set to any valid JavaScript number. Changes
63
+ * will affect any stack trace captured _after_ the value has been changed.
64
+ *
65
+ * If set to a non-number value, or set to a negative number, stack traces will
66
+ * not capture any frames.
67
+ */
68
+ stackTraceLimit: number;
69
+ }
70
+
71
+ /**
72
+ * Enable this API with the `--expose-gc` CLI flag.
73
+ */
74
+ declare var gc: NodeJS.GCFunction | undefined;
75
+
76
+ declare namespace NodeJS {
77
+ interface CallSite {
78
+ getColumnNumber(): number | null;
79
+ getEnclosingColumnNumber(): number | null;
80
+ getEnclosingLineNumber(): number | null;
81
+ getEvalOrigin(): string | undefined;
82
+ getFileName(): string | null;
83
+ getFunction(): Function | undefined;
84
+ getFunctionName(): string | null;
85
+ getLineNumber(): number | null;
86
+ getMethodName(): string | null;
87
+ getPosition(): number;
88
+ getPromiseIndex(): number | null;
89
+ getScriptHash(): string;
90
+ getScriptNameOrSourceURL(): string | null;
91
+ getThis(): unknown;
92
+ getTypeName(): string | null;
93
+ isAsync(): boolean;
94
+ isConstructor(): boolean;
95
+ isEval(): boolean;
96
+ isNative(): boolean;
97
+ isPromiseAll(): boolean;
98
+ isToplevel(): boolean;
99
+ }
100
+
101
+ interface ErrnoException extends Error {
102
+ errno?: number | undefined;
103
+ code?: string | undefined;
104
+ path?: string | undefined;
105
+ syscall?: string | undefined;
106
+ }
107
+
108
+ interface ReadableStream extends EventEmitter {
109
+ readable: boolean;
110
+ read(size?: number): string | Buffer;
111
+ setEncoding(encoding: BufferEncoding): this;
112
+ pause(): this;
113
+ resume(): this;
114
+ isPaused(): boolean;
115
+ pipe<T extends WritableStream>(destination: T, options?: { end?: boolean | undefined }): T;
116
+ unpipe(destination?: WritableStream): this;
117
+ unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
118
+ wrap(oldStream: ReadableStream): this;
119
+ [Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
120
+ }
121
+
122
+ interface WritableStream extends EventEmitter {
123
+ writable: boolean;
124
+ write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
125
+ write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
126
+ end(cb?: () => void): this;
127
+ end(data: string | Uint8Array, cb?: () => void): this;
128
+ end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
129
+ }
130
+
131
+ interface ReadWriteStream extends ReadableStream, WritableStream {}
132
+
133
+ interface RefCounted {
134
+ ref(): this;
135
+ unref(): this;
136
+ }
137
+
138
+ interface Dict<T> {
139
+ [key: string]: T | undefined;
140
+ }
141
+
142
+ interface ReadOnlyDict<T> {
143
+ readonly [key: string]: T | undefined;
144
+ }
145
+
146
+ type PartialOptions<T> = { [K in keyof T]?: T[K] | undefined };
147
+
148
+ interface GCFunction {
149
+ (minor?: boolean): void;
150
+ (options: NodeJS.GCOptions & { execution: "async" }): Promise<void>;
151
+ (options: NodeJS.GCOptions): void;
152
+ }
153
+
154
+ interface GCOptions {
155
+ execution?: "sync" | "async" | undefined;
156
+ flavor?: "regular" | "last-resort" | undefined;
157
+ type?: "major-snapshot" | "major" | "minor" | undefined;
158
+ filename?: string | undefined;
159
+ }
160
+
161
+ /** An iterable iterator returned by the Node.js API. */
162
+ // Default TReturn/TNext in v22 is `any`, for compatibility with the previously-used IterableIterator.
163
+ interface Iterator<T, TReturn = any, TNext = any> extends IteratorObject<T, TReturn, TNext> {
164
+ [Symbol.iterator](): NodeJS.Iterator<T, TReturn, TNext>;
165
+ }
166
+
167
+ /** An async iterable iterator returned by the Node.js API. */
168
+ // Default TReturn/TNext in v22 is `any`, for compatibility with the previously-used AsyncIterableIterator.
169
+ interface AsyncIterator<T, TReturn = any, TNext = any> extends AsyncIteratorObject<T, TReturn, TNext> {
170
+ [Symbol.asyncIterator](): NodeJS.AsyncIterator<T, TReturn, TNext>;
171
+ }
172
+ }
@@ -95,6 +95,10 @@ declare module "http" {
95
95
  range?: string | undefined;
96
96
  referer?: string | undefined;
97
97
  "retry-after"?: string | undefined;
98
+ "sec-fetch-site"?: string | undefined;
99
+ "sec-fetch-mode"?: string | undefined;
100
+ "sec-fetch-user"?: string | undefined;
101
+ "sec-fetch-dest"?: string | undefined;
98
102
  "sec-websocket-accept"?: string | undefined;
99
103
  "sec-websocket-extensions"?: string | undefined;
100
104
  "sec-websocket-key"?: string | undefined;
@@ -907,7 +911,7 @@ declare module "http" {
907
911
  * the request body should be sent.
908
912
  * @since v10.0.0
909
913
  */
910
- writeProcessing(): void;
914
+ writeProcessing(callback?: () => void): void;
911
915
  }
912
916
  interface InformationEvent {
913
917
  statusCode: number;
@@ -1415,7 +1419,7 @@ declare module "http" {
1415
1419
  */
1416
1420
  destroy(error?: Error): this;
1417
1421
  }
1418
- interface AgentOptions extends Partial<TcpSocketConnectOpts> {
1422
+ interface AgentOptions extends NodeJS.PartialOptions<TcpSocketConnectOpts> {
1419
1423
  /**
1420
1424
  * Keep sockets around in a pool to be used by other requests in the future. Default = false
1421
1425
  */
@@ -1566,6 +1570,68 @@ declare module "http" {
1566
1570
  * @since v0.11.4
1567
1571
  */
1568
1572
  destroy(): void;
1573
+ /**
1574
+ * Produces a socket/stream to be used for HTTP requests.
1575
+ *
1576
+ * By default, this function is the same as `net.createConnection()`. However,
1577
+ * custom agents may override this method in case greater flexibility is desired.
1578
+ *
1579
+ * A socket/stream can be supplied in one of two ways: by returning the
1580
+ * socket/stream from this function, or by passing the socket/stream to `callback`.
1581
+ *
1582
+ * This method is guaranteed to return an instance of the `net.Socket` class,
1583
+ * a subclass of `stream.Duplex`, unless the user specifies a socket
1584
+ * type other than `net.Socket`.
1585
+ *
1586
+ * `callback` has a signature of `(err, stream)`.
1587
+ * @since v0.11.4
1588
+ * @param options Options containing connection details. Check `createConnection` for the format of the options
1589
+ * @param callback Callback function that receives the created socket
1590
+ */
1591
+ createConnection(
1592
+ options: ClientRequestArgs,
1593
+ callback?: (err: Error | null, stream: stream.Duplex) => void,
1594
+ ): stream.Duplex | null | undefined;
1595
+ /**
1596
+ * Called when `socket` is detached from a request and could be persisted by the`Agent`. Default behavior is to:
1597
+ *
1598
+ * ```js
1599
+ * socket.setKeepAlive(true, this.keepAliveMsecs);
1600
+ * socket.unref();
1601
+ * return true;
1602
+ * ```
1603
+ *
1604
+ * This method can be overridden by a particular `Agent` subclass. If this
1605
+ * method returns a falsy value, the socket will be destroyed instead of persisting
1606
+ * it for use with the next request.
1607
+ *
1608
+ * The `socket` argument can be an instance of `net.Socket`, a subclass of `stream.Duplex`.
1609
+ * @since v8.1.0
1610
+ */
1611
+ keepSocketAlive(socket: stream.Duplex): void;
1612
+ /**
1613
+ * Called when `socket` is attached to `request` after being persisted because of
1614
+ * the keep-alive options. Default behavior is to:
1615
+ *
1616
+ * ```js
1617
+ * socket.ref();
1618
+ * ```
1619
+ *
1620
+ * This method can be overridden by a particular `Agent` subclass.
1621
+ *
1622
+ * The `socket` argument can be an instance of `net.Socket`, a subclass of `stream.Duplex`.
1623
+ * @since v8.1.0
1624
+ */
1625
+ reuseSocket(socket: stream.Duplex, request: ClientRequest): void;
1626
+ /**
1627
+ * Get a unique name for a set of request options, to determine whether a
1628
+ * connection can be reused. For an HTTP agent, this returns`host:port:localAddress` or `host:port:localAddress:family`. For an HTTPS agent,
1629
+ * the name includes the CA, cert, ciphers, and other HTTPS/TLS-specific options
1630
+ * that determine socket reusability.
1631
+ * @since v0.11.4
1632
+ * @param options A set of options providing information for name generation
1633
+ */
1634
+ getName(options?: ClientRequestArgs): string;
1569
1635
  }
1570
1636
  const METHODS: string[];
1571
1637
  const STATUS_CODES: {
@@ -1962,18 +2028,18 @@ declare module "http" {
1962
2028
  */
1963
2029
  const maxHeaderSize: number;
1964
2030
  /**
1965
- * A browser-compatible implementation of [WebSocket](https://nodejs.org/docs/latest/api/http.html#websocket).
2031
+ * A browser-compatible implementation of `WebSocket`.
1966
2032
  * @since v22.5.0
1967
2033
  */
1968
- const WebSocket: import("undici-types").WebSocket;
2034
+ const WebSocket: typeof import("undici-types").WebSocket;
1969
2035
  /**
1970
2036
  * @since v22.5.0
1971
2037
  */
1972
- const CloseEvent: import("undici-types").CloseEvent;
2038
+ const CloseEvent: typeof import("undici-types").CloseEvent;
1973
2039
  /**
1974
2040
  * @since v22.5.0
1975
2041
  */
1976
- const MessageEvent: import("undici-types").MessageEvent;
2042
+ const MessageEvent: typeof import("undici-types").MessageEvent;
1977
2043
  }
1978
2044
  declare module "node:http" {
1979
2045
  export * from "http";
@@ -965,7 +965,10 @@ declare module "http2" {
965
965
  * * `:path` \= `/`
966
966
  * @since v8.4.0
967
967
  */
968
- request(headers?: OutgoingHttpHeaders, options?: ClientSessionRequestOptions): ClientHttp2Stream;
968
+ request(
969
+ headers?: OutgoingHttpHeaders | readonly string[],
970
+ options?: ClientSessionRequestOptions,
971
+ ): ClientHttp2Stream;
969
972
  addListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
970
973
  addListener(event: "origin", listener: (origins: string[]) => void): this;
971
974
  addListener(
@@ -1223,14 +1226,66 @@ declare module "http2" {
1223
1226
  }
1224
1227
  // Http2Server
1225
1228
  export interface SessionOptions {
1229
+ /**
1230
+ * Sets the maximum dynamic table size for deflating header fields.
1231
+ * @default 4Kib
1232
+ */
1226
1233
  maxDeflateDynamicTableSize?: number | undefined;
1234
+ /**
1235
+ * Sets the maximum number of settings entries per `SETTINGS` frame.
1236
+ * The minimum value allowed is `1`.
1237
+ * @default 32
1238
+ */
1239
+ maxSettings?: number | undefined;
1240
+ /**
1241
+ * Sets the maximum memory that the `Http2Session` is permitted to use.
1242
+ * The value is expressed in terms of number of megabytes, e.g. `1` equal 1 megabyte.
1243
+ * The minimum value allowed is `1`.
1244
+ * This is a credit based limit, existing `Http2Stream`s may cause this limit to be exceeded,
1245
+ * but new `Http2Stream` instances will be rejected while this limit is exceeded.
1246
+ * The current number of `Http2Stream` sessions, the current memory use of the header compression tables,
1247
+ * current data queued to be sent, and unacknowledged `PING` and `SETTINGS` frames are all counted towards the current limit.
1248
+ * @default 10
1249
+ */
1227
1250
  maxSessionMemory?: number | undefined;
1251
+ /**
1252
+ * Sets the maximum number of header entries.
1253
+ * This is similar to `server.maxHeadersCount` or `request.maxHeadersCount` in the `node:http` module.
1254
+ * The minimum value is `1`.
1255
+ * @default 128
1256
+ */
1228
1257
  maxHeaderListPairs?: number | undefined;
1258
+ /**
1259
+ * Sets the maximum number of outstanding, unacknowledged pings.
1260
+ * @default 10
1261
+ */
1229
1262
  maxOutstandingPings?: number | undefined;
1263
+ /**
1264
+ * Sets the maximum allowed size for a serialized, compressed block of headers.
1265
+ * Attempts to send headers that exceed this limit will result in
1266
+ * a `'frameError'` event being emitted and the stream being closed and destroyed.
1267
+ */
1230
1268
  maxSendHeaderBlockLength?: number | undefined;
1269
+ /**
1270
+ * Strategy used for determining the amount of padding to use for `HEADERS` and `DATA` frames.
1271
+ * @default http2.constants.PADDING_STRATEGY_NONE
1272
+ */
1231
1273
  paddingStrategy?: number | undefined;
1274
+ /**
1275
+ * Sets the maximum number of concurrent streams for the remote peer as if a `SETTINGS` frame had been received.
1276
+ * Will be overridden if the remote peer sets its own value for `maxConcurrentStreams`.
1277
+ * @default 100
1278
+ */
1232
1279
  peerMaxConcurrentStreams?: number | undefined;
1280
+ /**
1281
+ * The initial settings to send to the remote peer upon connection.
1282
+ */
1233
1283
  settings?: Settings | undefined;
1284
+ /**
1285
+ * The array of integer values determines the settings types,
1286
+ * which are included in the `CustomSettings`-property of the received remoteSettings.
1287
+ * Please see the `CustomSettings`-property of the `Http2Settings` object for more information, on the allowed setting types.
1288
+ */
1234
1289
  remoteCustomSettings?: number[] | undefined;
1235
1290
  /**
1236
1291
  * Specifies a timeout in milliseconds that
@@ -1239,11 +1294,35 @@ declare module "http2" {
1239
1294
  * @default 100000
1240
1295
  */
1241
1296
  unknownProtocolTimeout?: number | undefined;
1242
- selectPadding?(frameLen: number, maxFrameLen: number): number;
1297
+ /**
1298
+ * If `true`, it turns on strict leading
1299
+ * and trailing whitespace validation for HTTP/2 header field names and values
1300
+ * as per [RFC-9113](https://www.rfc-editor.org/rfc/rfc9113.html#section-8.2.1).
1301
+ * @since v24.2.0
1302
+ * @default true
1303
+ */
1304
+ strictFieldWhitespaceValidation?: boolean | undefined;
1243
1305
  }
1244
1306
  export interface ClientSessionOptions extends SessionOptions {
1307
+ /**
1308
+ * Sets the maximum number of reserved push streams the client will accept at any given time.
1309
+ * Once the current number of currently reserved push streams exceeds reaches this limit,
1310
+ * new push streams sent by the server will be automatically rejected.
1311
+ * The minimum allowed value is 0. The maximum allowed value is 2<sup>32</sup>-1.
1312
+ * A negative value sets this option to the maximum allowed value.
1313
+ * @default 200
1314
+ */
1245
1315
  maxReservedRemoteStreams?: number | undefined;
1316
+ /**
1317
+ * An optional callback that receives the `URL` instance passed to `connect` and the `options` object,
1318
+ * and returns any `Duplex` stream that is to be used as the connection for this session.
1319
+ */
1246
1320
  createConnection?: ((authority: url.URL, option: SessionOptions) => stream.Duplex) | undefined;
1321
+ /**
1322
+ * The protocol to connect with, if not set in the `authority`.
1323
+ * Value may be either `'http:'` or `'https:'`.
1324
+ * @default 'https:'
1325
+ */
1247
1326
  protocol?: "http:" | "https:" | undefined;
1248
1327
  }
1249
1328
  export interface ServerSessionOptions<
@@ -32,6 +32,11 @@ declare module "https" {
32
32
  class Agent extends http.Agent {
33
33
  constructor(options?: AgentOptions);
34
34
  options: AgentOptions;
35
+ createConnection(
36
+ options: RequestOptions,
37
+ callback?: (err: Error | null, stream: Duplex) => void,
38
+ ): Duplex | null | undefined;
39
+ getName(options?: RequestOptions): string;
35
40
  }
36
41
  interface Server<
37
42
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,