@types/node 22.15.33 → 22.18.8

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 (75) hide show
  1. node v22.18/README.md +15 -0
  2. {node v22.15 → node v22.18}/assert.d.ts +19 -0
  3. {node v22.15 → node v22.18}/buffer.d.ts +6 -2
  4. {node v22.15 → node v22.18}/child_process.d.ts +26 -122
  5. {node v22.15 → node v22.18}/crypto.d.ts +17 -1
  6. {node v22.15 → node v22.18}/dns/promises.d.ts +11 -10
  7. {node v22.15 → node v22.18}/dns.d.ts +18 -19
  8. {node v22.15 → node v22.18}/events.d.ts +79 -34
  9. {node v22.15 → node v22.18}/fs/promises.d.ts +41 -37
  10. {node v22.15 → node v22.18}/fs.d.ts +55 -44
  11. node v22.18/globals.d.ts +170 -0
  12. {node v22.15 → node v22.18}/http.d.ts +67 -5
  13. {node v22.15 → node v22.18}/http2.d.ts +12 -1
  14. {node v22.15 → node v22.18}/https.d.ts +5 -0
  15. {node v22.15 → node v22.18}/index.d.ts +7 -3
  16. node v22.15/inspector.d.ts → node v22.18/inspector.generated.d.ts +219 -10
  17. {node v22.15 → node v22.18}/module.d.ts +70 -13
  18. {node v22.15 → node v22.18}/package.json +3 -83
  19. {node v22.15 → node v22.18}/process.d.ts +3 -4
  20. {node v22.15 → node v22.18}/readline/promises.d.ts +0 -1
  21. {node v22.15 → node v22.18}/repl.d.ts +3 -5
  22. {node v22.15 → node v22.18}/sqlite.d.ts +207 -0
  23. {node v22.15 → node v22.18}/stream/web.d.ts +8 -0
  24. {node v22.15 → node v22.18}/stream.d.ts +0 -11
  25. node v22.18/test.d.ts +2162 -0
  26. {node v22.15 → node v22.18}/ts5.6/index.d.ts +7 -3
  27. {node v22.15 → node v22.18}/url.d.ts +12 -3
  28. {node v22.15 → node v22.18}/util.d.ts +19 -4
  29. {node v22.15 → node v22.18}/v8.d.ts +27 -30
  30. node v22.18/web-globals/abortcontroller.d.ts +34 -0
  31. node v22.18/web-globals/domexception.d.ts +68 -0
  32. node v22.15/dom-events.d.ts → node v22.18/web-globals/events.d.ts +49 -51
  33. node v22.18/web-globals/fetch.d.ts +46 -0
  34. node v22.18/web-globals/navigator.d.ts +22 -0
  35. node v22.18/web-globals/storage.d.ts +24 -0
  36. {node v22.15 → node v22.18}/worker_threads.d.ts +86 -67
  37. {node v22.15 → node v22.18}/zlib.d.ts +8 -2
  38. node v22.15/README.md +0 -15
  39. node v22.15/globals.d.ts +0 -364
  40. node v22.15/test.d.ts +0 -2278
  41. {node v22.15 → node v22.18}/LICENSE +0 -0
  42. {node v22.15 → node v22.18}/assert/strict.d.ts +0 -0
  43. {node v22.15 → node v22.18}/async_hooks.d.ts +1 -1
  44. {node v22.15 → node v22.18}/buffer.buffer.d.ts +0 -0
  45. {node v22.15 → node v22.18}/cluster.d.ts +0 -0
  46. {node v22.15 → node v22.18}/compatibility/disposable.d.ts +0 -0
  47. {node v22.15 → node v22.18}/compatibility/index.d.ts +0 -0
  48. {node v22.15 → node v22.18}/compatibility/indexable.d.ts +0 -0
  49. {node v22.15 → node v22.18}/compatibility/iterators.d.ts +0 -0
  50. {node v22.15 → node v22.18}/console.d.ts +0 -0
  51. {node v22.15 → node v22.18}/constants.d.ts +0 -0
  52. {node v22.15 → node v22.18}/dgram.d.ts +0 -0
  53. {node v22.15 → node v22.18}/diagnostics_channel.d.ts +0 -0
  54. {node v22.15 → node v22.18}/domain.d.ts +0 -0
  55. {node v22.15 → node v22.18}/globals.typedarray.d.ts +0 -0
  56. {node v22.15 → node v22.18}/net.d.ts +0 -0
  57. {node v22.15 → node v22.18}/os.d.ts +0 -0
  58. {node v22.15 → node v22.18}/path.d.ts +0 -0
  59. {node v22.15 → node v22.18}/perf_hooks.d.ts +0 -0
  60. {node v22.15 → node v22.18}/punycode.d.ts +0 -0
  61. {node v22.15 → node v22.18}/querystring.d.ts +0 -0
  62. {node v22.15 → node v22.18}/readline.d.ts +0 -0
  63. {node v22.15 → node v22.18}/sea.d.ts +0 -0
  64. {node v22.15 → node v22.18}/stream/consumers.d.ts +0 -0
  65. {node v22.15 → node v22.18}/stream/promises.d.ts +0 -0
  66. {node v22.15 → node v22.18}/string_decoder.d.ts +0 -0
  67. {node v22.15 → node v22.18}/timers/promises.d.ts +0 -0
  68. {node v22.15 → node v22.18}/timers.d.ts +0 -0
  69. {node v22.15 → node v22.18}/tls.d.ts +0 -0
  70. {node v22.15 → node v22.18}/trace_events.d.ts +0 -0
  71. {node v22.15 → node v22.18}/ts5.6/buffer.buffer.d.ts +0 -0
  72. {node v22.15 → node v22.18}/ts5.6/globals.typedarray.d.ts +0 -0
  73. {node v22.15 → node v22.18}/tty.d.ts +0 -0
  74. {node v22.15 → node v22.18}/vm.d.ts +0 -0
  75. {node v22.15 → node v22.18}/wasi.d.ts +0 -0
@@ -40,7 +40,7 @@ declare module "fs/promises" {
40
40
  StatsFs,
41
41
  TimeLike,
42
42
  WatchEventType,
43
- WatchOptions,
43
+ WatchOptions as _WatchOptions,
44
44
  WriteStream,
45
45
  WriteVResult,
46
46
  } from "node:fs";
@@ -88,6 +88,9 @@ declare module "fs/promises" {
88
88
  highWaterMark?: number | undefined;
89
89
  flush?: boolean | undefined;
90
90
  }
91
+ interface ReadableWebStreamOptions {
92
+ autoClose?: boolean | undefined;
93
+ }
91
94
  // TODO: Add `EventEmitter` close
92
95
  interface FileHandle {
93
96
  /**
@@ -260,9 +263,8 @@ declare module "fs/promises" {
260
263
  * While the `ReadableStream` will read the file to completion, it will not
261
264
  * close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method.
262
265
  * @since v17.0.0
263
- * @experimental
264
266
  */
265
- readableWebStream(): ReadableStream;
267
+ readableWebStream(options?: ReadableWebStreamOptions): ReadableStream;
266
268
  /**
267
269
  * Asynchronously reads the entire contents of a file.
268
270
  *
@@ -475,7 +477,8 @@ declare module "fs/promises" {
475
477
  */
476
478
  close(): Promise<void>;
477
479
  /**
478
- * An alias for {@link FileHandle.close()}.
480
+ * Calls `filehandle.close()` and returns a promise that fulfills when the
481
+ * filehandle is closed.
479
482
  * @since v20.4.0
480
483
  */
481
484
  [Symbol.asyncDispose](): Promise<void>;
@@ -1179,6 +1182,16 @@ declare module "fs/promises" {
1179
1182
  * @return Fulfills with an {fs.Dir}.
1180
1183
  */
1181
1184
  function opendir(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
1185
+ interface WatchOptions extends _WatchOptions {
1186
+ maxQueue?: number | undefined;
1187
+ overflow?: "ignore" | "throw" | undefined;
1188
+ }
1189
+ interface WatchOptionsWithBufferEncoding extends WatchOptions {
1190
+ encoding: "buffer";
1191
+ }
1192
+ interface WatchOptionsWithStringEncoding extends WatchOptions {
1193
+ encoding?: BufferEncoding | undefined;
1194
+ }
1182
1195
  /**
1183
1196
  * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
1184
1197
  *
@@ -1211,33 +1224,16 @@ declare module "fs/promises" {
1211
1224
  */
1212
1225
  function watch(
1213
1226
  filename: PathLike,
1214
- options:
1215
- | (WatchOptions & {
1216
- encoding: "buffer";
1217
- })
1218
- | "buffer",
1219
- ): AsyncIterable<FileChangeInfo<Buffer>>;
1220
- /**
1221
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1222
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1223
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1224
- * If `encoding` is not supplied, the default of `'utf8'` is used.
1225
- * If `persistent` is not supplied, the default of `true` is used.
1226
- * If `recursive` is not supplied, the default of `false` is used.
1227
- */
1228
- function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable<FileChangeInfo<string>>;
1229
- /**
1230
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1231
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1232
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1233
- * If `encoding` is not supplied, the default of `'utf8'` is used.
1234
- * If `persistent` is not supplied, the default of `true` is used.
1235
- * If `recursive` is not supplied, the default of `false` is used.
1236
- */
1227
+ options?: WatchOptionsWithStringEncoding | BufferEncoding,
1228
+ ): NodeJS.AsyncIterator<FileChangeInfo<string>>;
1237
1229
  function watch(
1238
1230
  filename: PathLike,
1239
- options: WatchOptions | string,
1240
- ): AsyncIterable<FileChangeInfo<string>> | AsyncIterable<FileChangeInfo<Buffer>>;
1231
+ options: WatchOptionsWithBufferEncoding | "buffer",
1232
+ ): NodeJS.AsyncIterator<FileChangeInfo<Buffer>>;
1233
+ function watch(
1234
+ filename: PathLike,
1235
+ options: WatchOptions | BufferEncoding | "buffer",
1236
+ ): NodeJS.AsyncIterator<FileChangeInfo<string | Buffer>>;
1241
1237
  /**
1242
1238
  * Asynchronously copies the entire directory structure from `src` to `dest`,
1243
1239
  * including subdirectories and files.
@@ -1252,20 +1248,28 @@ declare module "fs/promises" {
1252
1248
  */
1253
1249
  function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
1254
1250
  /**
1255
- * Retrieves the files matching the specified pattern.
1251
+ * ```js
1252
+ * import { glob } from 'node:fs/promises';
1253
+ *
1254
+ * for await (const entry of glob('*.js'))
1255
+ * console.log(entry);
1256
+ * ```
1257
+ * @since v22.0.0
1258
+ * @returns An AsyncIterator that yields the paths of files
1259
+ * that match the pattern.
1256
1260
  */
1257
- function glob(pattern: string | string[]): NodeJS.AsyncIterator<string>;
1261
+ function glob(pattern: string | readonly string[]): NodeJS.AsyncIterator<string>;
1258
1262
  function glob(
1259
- pattern: string | string[],
1260
- opt: GlobOptionsWithFileTypes,
1263
+ pattern: string | readonly string[],
1264
+ options: GlobOptionsWithFileTypes,
1261
1265
  ): NodeJS.AsyncIterator<Dirent>;
1262
1266
  function glob(
1263
- pattern: string | string[],
1264
- opt: GlobOptionsWithoutFileTypes,
1267
+ pattern: string | readonly string[],
1268
+ options: GlobOptionsWithoutFileTypes,
1265
1269
  ): NodeJS.AsyncIterator<string>;
1266
1270
  function glob(
1267
- pattern: string | string[],
1268
- opt: GlobOptions,
1271
+ pattern: string | readonly string[],
1272
+ options: GlobOptions,
1269
1273
  ): NodeJS.AsyncIterator<Dirent | string>;
1270
1274
  }
1271
1275
  declare module "node:fs/promises" {
@@ -243,8 +243,8 @@ declare module "fs" {
243
243
  */
244
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
@@ -3327,6 +3341,12 @@ declare module "fs" {
3327
3341
  persistent?: boolean | undefined;
3328
3342
  recursive?: boolean | undefined;
3329
3343
  }
3344
+ export interface WatchOptionsWithBufferEncoding extends WatchOptions {
3345
+ encoding: "buffer";
3346
+ }
3347
+ export interface WatchOptionsWithStringEncoding extends WatchOptions {
3348
+ encoding?: BufferEncoding | undefined;
3349
+ }
3330
3350
  export type WatchEventType = "rename" | "change";
3331
3351
  export type WatchListener<T> = (event: WatchEventType, filename: T | null) => void;
3332
3352
  export type StatsListener = (curr: Stats, prev: Stats) => void;
@@ -3353,44 +3373,20 @@ declare module "fs" {
3353
3373
  */
3354
3374
  export function watch(
3355
3375
  filename: PathLike,
3356
- options:
3357
- | (WatchOptions & {
3358
- encoding: "buffer";
3359
- })
3360
- | "buffer",
3361
- listener?: WatchListener<Buffer>,
3376
+ options?: WatchOptionsWithStringEncoding | BufferEncoding | null,
3377
+ listener?: WatchListener<string>,
3362
3378
  ): FSWatcher;
3363
- /**
3364
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3365
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3366
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
3367
- * If `encoding` is not supplied, the default of `'utf8'` is used.
3368
- * If `persistent` is not supplied, the default of `true` is used.
3369
- * If `recursive` is not supplied, the default of `false` is used.
3370
- */
3371
3379
  export function watch(
3372
3380
  filename: PathLike,
3373
- options?: WatchOptions | BufferEncoding | null,
3374
- listener?: WatchListener<string>,
3381
+ options: WatchOptionsWithBufferEncoding | "buffer",
3382
+ listener: WatchListener<Buffer>,
3375
3383
  ): FSWatcher;
3376
- /**
3377
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3378
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3379
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
3380
- * If `encoding` is not supplied, the default of `'utf8'` is used.
3381
- * If `persistent` is not supplied, the default of `true` is used.
3382
- * If `recursive` is not supplied, the default of `false` is used.
3383
- */
3384
3384
  export function watch(
3385
3385
  filename: PathLike,
3386
- options: WatchOptions | string,
3387
- listener?: WatchListener<string | Buffer>,
3386
+ options: WatchOptions | BufferEncoding | "buffer" | null,
3387
+ listener: WatchListener<string | Buffer>,
3388
3388
  ): FSWatcher;
3389
- /**
3390
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3391
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3392
- */
3393
- export function watch(filename: PathLike, listener?: WatchListener<string>): FSWatcher;
3389
+ export function watch(filename: PathLike, listener: WatchListener<string>): FSWatcher;
3394
3390
  /**
3395
3391
  * Test whether or not the given path exists by checking with the file system.
3396
3392
  * Then call the `callback` argument with either true or false:
@@ -4200,7 +4196,6 @@ declare module "fs" {
4200
4196
  * blob.stream();
4201
4197
  * ```
4202
4198
  * @since v19.8.0
4203
- * @experimental
4204
4199
  */
4205
4200
  export function openAsBlob(path: PathLike, options?: OpenAsBlobOptions): Promise<Blob>;
4206
4201
 
@@ -4361,7 +4356,7 @@ declare module "fs" {
4361
4356
  * Current working directory.
4362
4357
  * @default process.cwd()
4363
4358
  */
4364
- cwd?: string | undefined;
4359
+ cwd?: string | URL | undefined;
4365
4360
  /**
4366
4361
  * `true` if the glob should return paths as `Dirent`s, `false` otherwise.
4367
4362
  * @default false
@@ -4386,13 +4381,23 @@ declare module "fs" {
4386
4381
 
4387
4382
  /**
4388
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
4389
4394
  */
4390
4395
  export function glob(
4391
- pattern: string | string[],
4396
+ pattern: string | readonly string[],
4392
4397
  callback: (err: NodeJS.ErrnoException | null, matches: string[]) => void,
4393
4398
  ): void;
4394
4399
  export function glob(
4395
- pattern: string | string[],
4400
+ pattern: string | readonly string[],
4396
4401
  options: GlobOptionsWithFileTypes,
4397
4402
  callback: (
4398
4403
  err: NodeJS.ErrnoException | null,
@@ -4400,7 +4405,7 @@ declare module "fs" {
4400
4405
  ) => void,
4401
4406
  ): void;
4402
4407
  export function glob(
4403
- pattern: string | string[],
4408
+ pattern: string | readonly string[],
4404
4409
  options: GlobOptionsWithoutFileTypes,
4405
4410
  callback: (
4406
4411
  err: NodeJS.ErrnoException | null,
@@ -4408,7 +4413,7 @@ declare module "fs" {
4408
4413
  ) => void,
4409
4414
  ): void;
4410
4415
  export function glob(
4411
- pattern: string | string[],
4416
+ pattern: string | readonly string[],
4412
4417
  options: GlobOptions,
4413
4418
  callback: (
4414
4419
  err: NodeJS.ErrnoException | null,
@@ -4416,19 +4421,25 @@ declare module "fs" {
4416
4421
  ) => void,
4417
4422
  ): void;
4418
4423
  /**
4419
- * 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.
4420
4431
  */
4421
- export function globSync(pattern: string | string[]): string[];
4432
+ export function globSync(pattern: string | readonly string[]): string[];
4422
4433
  export function globSync(
4423
- pattern: string | string[],
4434
+ pattern: string | readonly string[],
4424
4435
  options: GlobOptionsWithFileTypes,
4425
4436
  ): Dirent[];
4426
4437
  export function globSync(
4427
- pattern: string | string[],
4438
+ pattern: string | readonly string[],
4428
4439
  options: GlobOptionsWithoutFileTypes,
4429
4440
  ): string[];
4430
4441
  export function globSync(
4431
- pattern: string | string[],
4442
+ pattern: string | readonly string[],
4432
4443
  options: GlobOptions,
4433
4444
  ): Dirent[] | string[];
4434
4445
  }
@@ -0,0 +1,170 @@
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
+ interface GCFunction {
147
+ (minor?: boolean): void;
148
+ (options: NodeJS.GCOptions & { execution: "async" }): Promise<void>;
149
+ (options: NodeJS.GCOptions): void;
150
+ }
151
+
152
+ interface GCOptions {
153
+ execution?: "sync" | "async" | undefined;
154
+ flavor?: "regular" | "last-resort" | undefined;
155
+ type?: "major-snapshot" | "major" | "minor" | undefined;
156
+ filename?: string | undefined;
157
+ }
158
+
159
+ /** An iterable iterator returned by the Node.js API. */
160
+ // Default TReturn/TNext in v22 is `any`, for compatibility with the previously-used IterableIterator.
161
+ interface Iterator<T, TReturn = any, TNext = any> extends IteratorObject<T, TReturn, TNext> {
162
+ [Symbol.iterator](): NodeJS.Iterator<T, TReturn, TNext>;
163
+ }
164
+
165
+ /** An async iterable iterator returned by the Node.js API. */
166
+ // Default TReturn/TNext in v22 is `any`, for compatibility with the previously-used AsyncIterableIterator.
167
+ interface AsyncIterator<T, TReturn = any, TNext = any> extends AsyncIteratorObject<T, TReturn, TNext> {
168
+ [Symbol.asyncIterator](): NodeJS.AsyncIterator<T, TReturn, TNext>;
169
+ }
170
+ }
@@ -911,7 +911,7 @@ declare module "http" {
911
911
  * the request body should be sent.
912
912
  * @since v10.0.0
913
913
  */
914
- writeProcessing(): void;
914
+ writeProcessing(callback?: () => void): void;
915
915
  }
916
916
  interface InformationEvent {
917
917
  statusCode: number;
@@ -1570,6 +1570,68 @@ declare module "http" {
1570
1570
  * @since v0.11.4
1571
1571
  */
1572
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;
1573
1635
  }
1574
1636
  const METHODS: string[];
1575
1637
  const STATUS_CODES: {
@@ -1966,18 +2028,18 @@ declare module "http" {
1966
2028
  */
1967
2029
  const maxHeaderSize: number;
1968
2030
  /**
1969
- * A browser-compatible implementation of [WebSocket](https://nodejs.org/docs/latest/api/http.html#websocket).
2031
+ * A browser-compatible implementation of `WebSocket`.
1970
2032
  * @since v22.5.0
1971
2033
  */
1972
- const WebSocket: import("undici-types").WebSocket;
2034
+ const WebSocket: typeof import("undici-types").WebSocket;
1973
2035
  /**
1974
2036
  * @since v22.5.0
1975
2037
  */
1976
- const CloseEvent: import("undici-types").CloseEvent;
2038
+ const CloseEvent: typeof import("undici-types").CloseEvent;
1977
2039
  /**
1978
2040
  * @since v22.5.0
1979
2041
  */
1980
- const MessageEvent: import("undici-types").MessageEvent;
2042
+ const MessageEvent: typeof import("undici-types").MessageEvent;
1981
2043
  }
1982
2044
  declare module "node:http" {
1983
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(
@@ -1291,6 +1294,14 @@ declare module "http2" {
1291
1294
  * @default 100000
1292
1295
  */
1293
1296
  unknownProtocolTimeout?: number | undefined;
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;
1294
1305
  }
1295
1306
  export interface ClientSessionOptions extends SessionOptions {
1296
1307
  /**
@@ -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,
@@ -36,6 +36,12 @@
36
36
 
37
37
  // Definitions for Node.js modules that are not specific to any version of TypeScript:
38
38
  /// <reference path="globals.d.ts" />
39
+ /// <reference path="web-globals/abortcontroller.d.ts" />
40
+ /// <reference path="web-globals/domexception.d.ts" />
41
+ /// <reference path="web-globals/events.d.ts" />
42
+ /// <reference path="web-globals/fetch.d.ts" />
43
+ /// <reference path="web-globals/navigator.d.ts" />
44
+ /// <reference path="web-globals/storage.d.ts" />
39
45
  /// <reference path="assert.d.ts" />
40
46
  /// <reference path="assert/strict.d.ts" />
41
47
  /// <reference path="async_hooks.d.ts" />
@@ -49,16 +55,14 @@
49
55
  /// <reference path="diagnostics_channel.d.ts" />
50
56
  /// <reference path="dns.d.ts" />
51
57
  /// <reference path="dns/promises.d.ts" />
52
- /// <reference path="dns/promises.d.ts" />
53
58
  /// <reference path="domain.d.ts" />
54
- /// <reference path="dom-events.d.ts" />
55
59
  /// <reference path="events.d.ts" />
56
60
  /// <reference path="fs.d.ts" />
57
61
  /// <reference path="fs/promises.d.ts" />
58
62
  /// <reference path="http.d.ts" />
59
63
  /// <reference path="http2.d.ts" />
60
64
  /// <reference path="https.d.ts" />
61
- /// <reference path="inspector.d.ts" />
65
+ /// <reference path="inspector.generated.d.ts" />
62
66
  /// <reference path="module.d.ts" />
63
67
  /// <reference path="net.d.ts" />
64
68
  /// <reference path="os.d.ts" />