@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
@@ -250,6 +250,9 @@ declare module "dns" {
250
250
  contactemail?: string | undefined;
251
251
  contactphone?: string | undefined;
252
252
  }
253
+ export interface AnyCaaRecord extends CaaRecord {
254
+ type: "CAA";
255
+ }
253
256
  export interface MxRecord {
254
257
  priority: number;
255
258
  exchange: string;
@@ -289,6 +292,15 @@ declare module "dns" {
289
292
  export interface AnySrvRecord extends SrvRecord {
290
293
  type: "SRV";
291
294
  }
295
+ export interface TlsaRecord {
296
+ certUsage: number;
297
+ selector: number;
298
+ match: number;
299
+ data: ArrayBuffer;
300
+ }
301
+ export interface AnyTlsaRecord extends TlsaRecord {
302
+ type: "TLSA";
303
+ }
292
304
  export interface AnyTxtRecord {
293
305
  type: "TXT";
294
306
  entries: string[];
@@ -308,6 +320,7 @@ declare module "dns" {
308
320
  export type AnyRecord =
309
321
  | AnyARecord
310
322
  | AnyAaaaRecord
323
+ | AnyCaaRecord
311
324
  | AnyCnameRecord
312
325
  | AnyMxRecord
313
326
  | AnyNaptrRecord
@@ -315,6 +328,7 @@ declare module "dns" {
315
328
  | AnyPtrRecord
316
329
  | AnySoaRecord
317
330
  | AnySrvRecord
331
+ | AnyTlsaRecord
318
332
  | AnyTxtRecord;
319
333
  /**
320
334
  * Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
@@ -335,12 +349,7 @@ declare module "dns" {
335
349
  ): void;
336
350
  export function resolve(
337
351
  hostname: string,
338
- rrtype: "A",
339
- callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
340
- ): void;
341
- export function resolve(
342
- hostname: string,
343
- rrtype: "AAAA",
352
+ rrtype: "A" | "AAAA" | "CNAME" | "NS" | "PTR",
344
353
  callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
345
354
  ): void;
346
355
  export function resolve(
@@ -350,8 +359,8 @@ declare module "dns" {
350
359
  ): void;
351
360
  export function resolve(
352
361
  hostname: string,
353
- rrtype: "CNAME",
354
- callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
362
+ rrtype: "CAA",
363
+ callback: (err: NodeJS.ErrnoException | null, address: CaaRecord[]) => void,
355
364
  ): void;
356
365
  export function resolve(
357
366
  hostname: string,
@@ -363,16 +372,6 @@ declare module "dns" {
363
372
  rrtype: "NAPTR",
364
373
  callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void,
365
374
  ): void;
366
- export function resolve(
367
- hostname: string,
368
- rrtype: "NS",
369
- callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
370
- ): void;
371
- export function resolve(
372
- hostname: string,
373
- rrtype: "PTR",
374
- callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
375
- ): void;
376
375
  export function resolve(
377
376
  hostname: string,
378
377
  rrtype: "SOA",
@@ -383,6 +382,11 @@ declare module "dns" {
383
382
  rrtype: "SRV",
384
383
  callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void,
385
384
  ): void;
385
+ export function resolve(
386
+ hostname: string,
387
+ rrtype: "TLSA",
388
+ callback: (err: NodeJS.ErrnoException | null, addresses: TlsaRecord[]) => void,
389
+ ): void;
386
390
  export function resolve(
387
391
  hostname: string,
388
392
  rrtype: "TXT",
@@ -393,21 +397,42 @@ declare module "dns" {
393
397
  rrtype: string,
394
398
  callback: (
395
399
  err: NodeJS.ErrnoException | null,
396
- addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[],
400
+ addresses:
401
+ | string[]
402
+ | CaaRecord[]
403
+ | MxRecord[]
404
+ | NaptrRecord[]
405
+ | SoaRecord
406
+ | SrvRecord[]
407
+ | TlsaRecord[]
408
+ | string[][]
409
+ | AnyRecord[],
397
410
  ) => void,
398
411
  ): void;
399
412
  export namespace resolve {
400
413
  function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
401
414
  function __promisify__(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
415
+ function __promisify__(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;
402
416
  function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
403
417
  function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
404
418
  function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
405
419
  function __promisify__(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
420
+ function __promisify__(hostname: string, rrtype: "TLSA"): Promise<TlsaRecord[]>;
406
421
  function __promisify__(hostname: string, rrtype: "TXT"): Promise<string[][]>;
407
422
  function __promisify__(
408
423
  hostname: string,
409
424
  rrtype: string,
410
- ): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
425
+ ): Promise<
426
+ | string[]
427
+ | CaaRecord[]
428
+ | MxRecord[]
429
+ | NaptrRecord[]
430
+ | SoaRecord
431
+ | SrvRecord[]
432
+ | TlsaRecord[]
433
+ | string[][]
434
+ | AnyRecord[]
435
+ >;
411
436
  }
412
437
  /**
413
438
  * Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the `hostname`. The `addresses` argument passed to the `callback` function
@@ -609,6 +634,33 @@ declare module "dns" {
609
634
  export namespace resolveSrv {
610
635
  function __promisify__(hostname: string): Promise<SrvRecord[]>;
611
636
  }
637
+ /**
638
+ * Uses the DNS protocol to resolve certificate associations (`TLSA` records) for
639
+ * the `hostname`. The `records` argument passed to the `callback` function is an
640
+ * array of objects with these properties:
641
+ *
642
+ * * `certUsage`
643
+ * * `selector`
644
+ * * `match`
645
+ * * `data`
646
+ *
647
+ * ```js
648
+ * {
649
+ * certUsage: 3,
650
+ * selector: 1,
651
+ * match: 1,
652
+ * data: [ArrayBuffer]
653
+ * }
654
+ * ```
655
+ * @since v22.15.0
656
+ */
657
+ export function resolveTlsa(
658
+ hostname: string,
659
+ callback: (err: NodeJS.ErrnoException | null, addresses: TlsaRecord[]) => void,
660
+ ): void;
661
+ export namespace resolveTlsa {
662
+ function __promisify__(hostname: string): Promise<TlsaRecord[]>;
663
+ }
612
664
  /**
613
665
  * Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. The `records` argument passed to the `callback` function is a
614
666
  * two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
@@ -838,6 +890,7 @@ declare module "dns" {
838
890
  resolvePtr: typeof resolvePtr;
839
891
  resolveSoa: typeof resolveSoa;
840
892
  resolveSrv: typeof resolveSrv;
893
+ resolveTlsa: typeof resolveTlsa;
841
894
  resolveTxt: typeof resolveTxt;
842
895
  reverse: typeof reverse;
843
896
  /**
@@ -36,39 +36,6 @@
36
36
  */
37
37
  declare module "events" {
38
38
  import { AsyncResource, AsyncResourceOptions } from "node:async_hooks";
39
- // NOTE: This class is in the docs but is **not actually exported** by Node.
40
- // If https://github.com/nodejs/node/issues/39903 gets resolved and Node
41
- // actually starts exporting the class, uncomment below.
42
- // import { EventListener, EventListenerObject } from '__dom-events';
43
- // /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */
44
- // interface NodeEventTarget extends EventTarget {
45
- // /**
46
- // * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API.
47
- // * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget.
48
- // */
49
- // addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
50
- // /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */
51
- // eventNames(): string[];
52
- // /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */
53
- // listenerCount(type: string): number;
54
- // /** Node.js-specific alias for `eventTarget.removeListener()`. */
55
- // off(type: string, listener: EventListener | EventListenerObject): this;
56
- // /** Node.js-specific alias for `eventTarget.addListener()`. */
57
- // on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
58
- // /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */
59
- // once(type: string, listener: EventListener | EventListenerObject): this;
60
- // /**
61
- // * Node.js-specific extension to the `EventTarget` class.
62
- // * If `type` is specified, removes all registered listeners for `type`,
63
- // * otherwise removes all registered listeners.
64
- // */
65
- // removeAllListeners(type: string): this;
66
- // /**
67
- // * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`.
68
- // * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`.
69
- // */
70
- // removeListener(type: string, listener: EventListener | EventListenerObject): this;
71
- // }
72
39
  interface EventEmitterOptions {
73
40
  /**
74
41
  * Enables automatic capturing of promise rejection.
@@ -431,7 +398,6 @@ declare module "events" {
431
398
  * }
432
399
  * ```
433
400
  * @since v20.5.0
434
- * @experimental
435
401
  * @return Disposable that removes the `abort` listener.
436
402
  */
437
403
  static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable;
@@ -585,6 +551,85 @@ declare module "events" {
585
551
  */
586
552
  readonly asyncResource: EventEmitterReferencingAsyncResource;
587
553
  }
554
+ /**
555
+ * The `NodeEventTarget` is a Node.js-specific extension to `EventTarget`
556
+ * that emulates a subset of the `EventEmitter` API.
557
+ * @since v14.5.0
558
+ */
559
+ export interface NodeEventTarget extends EventTarget {
560
+ /**
561
+ * Node.js-specific extension to the `EventTarget` class that emulates the
562
+ * equivalent `EventEmitter` API. The only difference between `addListener()` and
563
+ * `addEventListener()` is that `addListener()` will return a reference to the
564
+ * `EventTarget`.
565
+ * @since v14.5.0
566
+ */
567
+ addListener(type: string, listener: (arg: any) => void): this;
568
+ /**
569
+ * Node.js-specific extension to the `EventTarget` class that dispatches the
570
+ * `arg` to the list of handlers for `type`.
571
+ * @since v15.2.0
572
+ * @returns `true` if event listeners registered for the `type` exist,
573
+ * otherwise `false`.
574
+ */
575
+ emit(type: string, arg: any): boolean;
576
+ /**
577
+ * Node.js-specific extension to the `EventTarget` class that returns an array
578
+ * of event `type` names for which event listeners are registered.
579
+ * @since 14.5.0
580
+ */
581
+ eventNames(): string[];
582
+ /**
583
+ * Node.js-specific extension to the `EventTarget` class that returns the number
584
+ * of event listeners registered for the `type`.
585
+ * @since v14.5.0
586
+ */
587
+ listenerCount(type: string): number;
588
+ /**
589
+ * Node.js-specific extension to the `EventTarget` class that sets the number
590
+ * of max event listeners as `n`.
591
+ * @since v14.5.0
592
+ */
593
+ setMaxListeners(n: number): void;
594
+ /**
595
+ * Node.js-specific extension to the `EventTarget` class that returns the number
596
+ * of max event listeners.
597
+ * @since v14.5.0
598
+ */
599
+ getMaxListeners(): number;
600
+ /**
601
+ * Node.js-specific alias for `eventTarget.removeEventListener()`.
602
+ * @since v14.5.0
603
+ */
604
+ off(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
605
+ /**
606
+ * Node.js-specific alias for `eventTarget.addEventListener()`.
607
+ * @since v14.5.0
608
+ */
609
+ on(type: string, listener: (arg: any) => void): this;
610
+ /**
611
+ * Node.js-specific extension to the `EventTarget` class that adds a `once`
612
+ * listener for the given event `type`. This is equivalent to calling `on`
613
+ * with the `once` option set to `true`.
614
+ * @since v14.5.0
615
+ */
616
+ once(type: string, listener: (arg: any) => void): this;
617
+ /**
618
+ * Node.js-specific extension to the `EventTarget` class. If `type` is specified,
619
+ * removes all registered listeners for `type`, otherwise removes all registered
620
+ * listeners.
621
+ * @since v14.5.0
622
+ */
623
+ removeAllListeners(type?: string): this;
624
+ /**
625
+ * Node.js-specific extension to the `EventTarget` class that removes the
626
+ * `listener` for the given `type`. The only difference between `removeListener()`
627
+ * and `removeEventListener()` is that `removeListener()` will return a reference
628
+ * to the `EventTarget`.
629
+ * @since v14.5.0
630
+ */
631
+ removeListener(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
632
+ }
588
633
  }
589
634
  global {
590
635
  namespace NodeJS {
@@ -29,6 +29,7 @@ declare module "fs/promises" {
29
29
  OpenDirOptions,
30
30
  OpenMode,
31
31
  PathLike,
32
+ ReadPosition,
32
33
  ReadStream,
33
34
  ReadVResult,
34
35
  RmDirOptions,
@@ -39,7 +40,7 @@ declare module "fs/promises" {
39
40
  StatsFs,
40
41
  TimeLike,
41
42
  WatchEventType,
42
- WatchOptions,
43
+ WatchOptions as _WatchOptions,
43
44
  WriteStream,
44
45
  WriteVResult,
45
46
  } from "node:fs";
@@ -69,7 +70,7 @@ declare module "fs/promises" {
69
70
  * @default `buffer.byteLength`
70
71
  */
71
72
  length?: number | null;
72
- position?: number | null;
73
+ position?: ReadPosition | null;
73
74
  }
74
75
  interface CreateReadStreamOptions extends Abortable {
75
76
  encoding?: BufferEncoding | null | undefined;
@@ -87,6 +88,9 @@ declare module "fs/promises" {
87
88
  highWaterMark?: number | undefined;
88
89
  flush?: boolean | undefined;
89
90
  }
91
+ interface ReadableWebStreamOptions {
92
+ autoClose?: boolean | undefined;
93
+ }
90
94
  // TODO: Add `EventEmitter` close
91
95
  interface FileHandle {
92
96
  /**
@@ -229,7 +233,7 @@ declare module "fs/promises" {
229
233
  buffer: T,
230
234
  offset?: number | null,
231
235
  length?: number | null,
232
- position?: number | null,
236
+ position?: ReadPosition | null,
233
237
  ): Promise<FileReadResult<T>>;
234
238
  read<T extends NodeJS.ArrayBufferView = Buffer>(
235
239
  buffer: T,
@@ -259,9 +263,8 @@ declare module "fs/promises" {
259
263
  * While the `ReadableStream` will read the file to completion, it will not
260
264
  * close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method.
261
265
  * @since v17.0.0
262
- * @experimental
263
266
  */
264
- readableWebStream(): ReadableStream;
267
+ readableWebStream(options?: ReadableWebStreamOptions): ReadableStream;
265
268
  /**
266
269
  * Asynchronously reads the entire contents of a file.
267
270
  *
@@ -474,7 +477,8 @@ declare module "fs/promises" {
474
477
  */
475
478
  close(): Promise<void>;
476
479
  /**
477
- * An alias for {@link FileHandle.close()}.
480
+ * Calls `filehandle.close()` and returns a promise that fulfills when the
481
+ * filehandle is closed.
478
482
  * @since v20.4.0
479
483
  */
480
484
  [Symbol.asyncDispose](): Promise<void>;
@@ -718,6 +722,19 @@ declare module "fs/promises" {
718
722
  recursive?: boolean | undefined;
719
723
  },
720
724
  ): Promise<Dirent[]>;
725
+ /**
726
+ * Asynchronous readdir(3) - read a directory.
727
+ * @param path A path to a directory. If a URL is provided, it must use the `file:` protocol.
728
+ * @param options Must include `withFileTypes: true` and `encoding: 'buffer'`.
729
+ */
730
+ function readdir(
731
+ path: PathLike,
732
+ options: {
733
+ encoding: "buffer";
734
+ withFileTypes: true;
735
+ recursive?: boolean | undefined;
736
+ },
737
+ ): Promise<Dirent<Buffer>[]>;
721
738
  /**
722
739
  * Reads the contents of the symbolic link referred to by `path`. See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is
723
740
  * fulfilled with the`linkString` upon success.
@@ -1165,6 +1182,16 @@ declare module "fs/promises" {
1165
1182
  * @return Fulfills with an {fs.Dir}.
1166
1183
  */
1167
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
+ }
1168
1195
  /**
1169
1196
  * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
1170
1197
  *
@@ -1197,33 +1224,16 @@ declare module "fs/promises" {
1197
1224
  */
1198
1225
  function watch(
1199
1226
  filename: PathLike,
1200
- options:
1201
- | (WatchOptions & {
1202
- encoding: "buffer";
1203
- })
1204
- | "buffer",
1205
- ): AsyncIterable<FileChangeInfo<Buffer>>;
1206
- /**
1207
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1208
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1209
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1210
- * If `encoding` is not supplied, the default of `'utf8'` is used.
1211
- * If `persistent` is not supplied, the default of `true` is used.
1212
- * If `recursive` is not supplied, the default of `false` is used.
1213
- */
1214
- function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable<FileChangeInfo<string>>;
1215
- /**
1216
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1217
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1218
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1219
- * If `encoding` is not supplied, the default of `'utf8'` is used.
1220
- * If `persistent` is not supplied, the default of `true` is used.
1221
- * If `recursive` is not supplied, the default of `false` is used.
1222
- */
1227
+ options?: WatchOptionsWithStringEncoding | BufferEncoding,
1228
+ ): NodeJS.AsyncIterator<FileChangeInfo<string>>;
1229
+ function watch(
1230
+ filename: PathLike,
1231
+ options: WatchOptionsWithBufferEncoding | "buffer",
1232
+ ): NodeJS.AsyncIterator<FileChangeInfo<Buffer>>;
1223
1233
  function watch(
1224
1234
  filename: PathLike,
1225
- options: WatchOptions | string,
1226
- ): AsyncIterable<FileChangeInfo<string>> | AsyncIterable<FileChangeInfo<Buffer>>;
1235
+ options: WatchOptions | BufferEncoding | "buffer",
1236
+ ): NodeJS.AsyncIterator<FileChangeInfo<string | Buffer>>;
1227
1237
  /**
1228
1238
  * Asynchronously copies the entire directory structure from `src` to `dest`,
1229
1239
  * including subdirectories and files.
@@ -1238,20 +1248,28 @@ declare module "fs/promises" {
1238
1248
  */
1239
1249
  function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
1240
1250
  /**
1241
- * 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.
1242
1260
  */
1243
- function glob(pattern: string | string[]): NodeJS.AsyncIterator<string>;
1261
+ function glob(pattern: string | readonly string[]): NodeJS.AsyncIterator<string>;
1244
1262
  function glob(
1245
- pattern: string | string[],
1246
- opt: GlobOptionsWithFileTypes,
1263
+ pattern: string | readonly string[],
1264
+ options: GlobOptionsWithFileTypes,
1247
1265
  ): NodeJS.AsyncIterator<Dirent>;
1248
1266
  function glob(
1249
- pattern: string | string[],
1250
- opt: GlobOptionsWithoutFileTypes,
1267
+ pattern: string | readonly string[],
1268
+ options: GlobOptionsWithoutFileTypes,
1251
1269
  ): NodeJS.AsyncIterator<string>;
1252
1270
  function glob(
1253
- pattern: string | string[],
1254
- opt: GlobOptions,
1271
+ pattern: string | readonly string[],
1272
+ options: GlobOptions,
1255
1273
  ): NodeJS.AsyncIterator<Dirent | string>;
1256
1274
  }
1257
1275
  declare module "node:fs/promises" {