@types/node 20.19.25 → 24.10.4

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 (79) hide show
  1. {node v20.19 → node v24.10}/README.md +3 -3
  2. node v24.10/assert/strict.d.ts +111 -0
  3. {node v20.19 → node v24.10}/assert.d.ts +150 -97
  4. {node v20.19 → node v24.10}/async_hooks.d.ts +27 -9
  5. {node v20.19 → node v24.10}/buffer.buffer.d.ts +2 -1
  6. {node v20.19 → node v24.10}/buffer.d.ts +6 -8
  7. {node v20.19 → node v24.10}/child_process.d.ts +11 -10
  8. {node v20.19 → node v24.10}/cluster.d.ts +16 -15
  9. {node v20.19 → node v24.10}/console.d.ts +19 -18
  10. {node v20.19 → node v24.10}/crypto.d.ts +1120 -293
  11. {node v20.19 → node v24.10}/dgram.d.ts +5 -2
  12. {node v20.19 → node v24.10}/diagnostics_channel.d.ts +1 -3
  13. {node v20.19 → node v24.10}/dns/promises.d.ts +30 -6
  14. {node v20.19 → node v24.10}/dns.d.ts +69 -17
  15. {node v20.19 → node v24.10}/domain.d.ts +1 -1
  16. {node v20.19 → node v24.10}/events.d.ts +1 -2
  17. {node v20.19 → node v24.10}/fs/promises.d.ts +85 -38
  18. {node v20.19 → node v24.10}/fs.d.ts +387 -48
  19. {node v20.19 → node v24.10}/globals.d.ts +2 -4
  20. {node v20.19 → node v24.10}/globals.typedarray.d.ts +3 -0
  21. {node v20.19 → node v24.10}/http.d.ts +90 -5
  22. {node v20.19 → node v24.10}/http2.d.ts +166 -41
  23. {node v20.19 → node v24.10}/https.d.ts +4 -3
  24. {node v20.19 → node v24.10}/index.d.ts +13 -5
  25. node v24.10/inspector.d.ts +277 -0
  26. {node v20.19 → node v24.10}/inspector.generated.d.ts +1096 -829
  27. {node v20.19 → node v24.10}/module.d.ts +403 -48
  28. {node v20.19 → node v24.10}/net.d.ts +62 -20
  29. {node v20.19 → node v24.10}/os.d.ts +8 -7
  30. {node v20.19 → node v24.10}/package.json +18 -3
  31. {node v20.19 → node v24.10}/path.d.ts +3 -3
  32. {node v20.19 → node v24.10}/perf_hooks.d.ts +37 -16
  33. {node v20.19 → node v24.10}/process.d.ts +138 -16
  34. {node v20.19 → node v24.10}/punycode.d.ts +1 -1
  35. {node v20.19 → node v24.10}/querystring.d.ts +1 -1
  36. {node v20.19 → node v24.10}/readline/promises.d.ts +0 -1
  37. {node v20.19 → node v24.10}/readline.d.ts +19 -14
  38. {node v20.19 → node v24.10}/repl.d.ts +25 -17
  39. {node v20.19 → node v24.10}/sea.d.ts +11 -2
  40. node v24.10/sqlite.d.ts +937 -0
  41. {node v20.19 → node v24.10}/stream/web.d.ts +85 -45
  42. {node v20.19 → node v24.10}/stream.d.ts +36 -28
  43. {node v20.19 → node v24.10}/string_decoder.d.ts +1 -1
  44. {node v20.19 → node v24.10}/test.d.ts +587 -35
  45. {node v20.19 → node v24.10}/timers/promises.d.ts +1 -1
  46. {node v20.19 → node v24.10}/timers.d.ts +4 -5
  47. {node v20.19 → node v24.10}/tls.d.ts +62 -48
  48. {node v20.19 → node v24.10}/trace_events.d.ts +6 -6
  49. node v24.10/ts5.6/compatibility/float16array.d.ts +71 -0
  50. {node v20.19 → node v24.10}/ts5.6/globals.typedarray.d.ts +2 -0
  51. {node v20.19 → node v24.10}/ts5.6/index.d.ts +15 -5
  52. node v24.10/ts5.7/compatibility/float16array.d.ts +72 -0
  53. node v24.10/ts5.7/index.d.ts +103 -0
  54. {node v20.19 → node v24.10}/tty.d.ts +1 -1
  55. {node v20.19 → node v24.10}/url.d.ts +128 -35
  56. {node v20.19 → node v24.10}/util.d.ts +384 -390
  57. {node v20.19 → node v24.10}/v8.d.ts +175 -32
  58. {node v20.19 → node v24.10}/vm.d.ts +246 -67
  59. {node v20.19 → node v24.10}/wasi.d.ts +23 -2
  60. node v24.10/web-globals/crypto.d.ts +32 -0
  61. {node v20.19 → node v24.10}/web-globals/fetch.d.ts +4 -0
  62. node v24.10/web-globals/navigator.d.ts +25 -0
  63. node v24.10/web-globals/storage.d.ts +24 -0
  64. node v24.10/web-globals/streams.d.ts +22 -0
  65. {node v20.19 → node v24.10}/worker_threads.d.ts +205 -24
  66. {node v20.19 → node v24.10}/zlib.d.ts +185 -44
  67. node v20.19/assert/strict.d.ts +0 -8
  68. node v20.19/compatibility/disposable.d.ts +0 -16
  69. node v20.19/compatibility/index.d.ts +0 -9
  70. node v20.19/compatibility/indexable.d.ts +0 -20
  71. {node v20.19 → node v24.10}/LICENSE +0 -0
  72. {node v20.19 → node v24.10}/compatibility/iterators.d.ts +0 -0
  73. {node v20.19 → node v24.10}/constants.d.ts +0 -0
  74. {node v20.19 → node v24.10}/stream/consumers.d.ts +0 -0
  75. {node v20.19 → node v24.10}/stream/promises.d.ts +0 -0
  76. {node v20.19 → node v24.10}/ts5.6/buffer.buffer.d.ts +0 -0
  77. {node v20.19 → node v24.10}/web-globals/abortcontroller.d.ts +0 -0
  78. {node v20.19 → node v24.10}/web-globals/domexception.d.ts +0 -0
  79. {node v20.19 → node v24.10}/web-globals/events.d.ts +0 -0
@@ -16,7 +16,7 @@
16
16
  *
17
17
  * All file system operations have synchronous, callback, and promise-based
18
18
  * forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).
19
- * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/fs.js)
19
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/fs.js)
20
20
  */
21
21
  declare module "fs" {
22
22
  import { NonSharedBuffer } from "node:buffer";
@@ -131,7 +131,9 @@ declare module "fs" {
131
131
  * ```
132
132
  * @since v0.1.21
133
133
  */
134
- export class Stats {}
134
+ export class Stats {
135
+ private constructor();
136
+ }
135
137
  export interface StatsFsBase<T> {
136
138
  /** Type of file system. */
137
139
  type: T;
@@ -242,16 +244,10 @@ declare module "fs" {
242
244
  */
243
245
  name: Name;
244
246
  /**
245
- * The base path that this `fs.Dirent` object refers to.
246
- * @since v20.12.0
247
+ * The path to the parent directory of the file this `fs.Dirent` object refers to.
248
+ * @since v20.12.0, v18.20.0
247
249
  */
248
250
  parentPath: string;
249
- /**
250
- * Alias for `dirent.parentPath`.
251
- * @since v20.1.0
252
- * @deprecated Since v20.12.0
253
- */
254
- path: string;
255
251
  }
256
252
  /**
257
253
  * A class representing a directory stream.
@@ -327,6 +323,18 @@ declare module "fs" {
327
323
  * @since v12.12.0
328
324
  */
329
325
  readSync(): Dirent | null;
326
+ /**
327
+ * Calls `dir.close()` if the directory handle is open, and returns a promise that
328
+ * fulfills when disposal is complete.
329
+ * @since v24.1.0
330
+ */
331
+ [Symbol.asyncDispose](): Promise<void>;
332
+ /**
333
+ * Calls `dir.closeSync()` if the directory handle is open, and returns
334
+ * `undefined`.
335
+ * @since v24.1.0
336
+ */
337
+ [Symbol.dispose](): void;
330
338
  }
331
339
  /**
332
340
  * Class: fs.StatWatcher
@@ -449,6 +457,230 @@ declare module "fs" {
449
457
  prependListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
450
458
  prependOnceListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
451
459
  }
460
+ export interface Utf8StreamOptions {
461
+ /**
462
+ * Appends writes to dest file instead of truncating it.
463
+ * @default true
464
+ */
465
+ append?: boolean | undefined;
466
+ /**
467
+ * Which type of data you can send to the write
468
+ * function, supported values are `'utf8'` or `'buffer'`.
469
+ * @default 'utf8'
470
+ */
471
+ contentMode?: "utf8" | "buffer" | undefined;
472
+ /**
473
+ * A path to a file to be written to (mode controlled by the
474
+ * append option).
475
+ */
476
+ dest?: string | undefined;
477
+ /**
478
+ * A file descriptor, something that is returned by `fs.open()`
479
+ * or `fs.openSync()`.
480
+ */
481
+ fd?: number | undefined;
482
+ /**
483
+ * An object that has the same API as the `fs` module, useful
484
+ * for mocking, testing, or customizing the behavior of the stream.
485
+ */
486
+ fs?: object | undefined;
487
+ /**
488
+ * Perform a `fs.fsyncSync()` every time a write is
489
+ * completed.
490
+ */
491
+ fsync?: boolean | undefined;
492
+ /**
493
+ * The maximum length of the internal buffer. If a write
494
+ * operation would cause the buffer to exceed `maxLength`, the data written is
495
+ * dropped and a drop event is emitted with the dropped data
496
+ */
497
+ maxLength?: number | undefined;
498
+ /**
499
+ * The maximum number of bytes that can be written;
500
+ * @default 16384
501
+ */
502
+ maxWrite?: number | undefined;
503
+ /**
504
+ * The minimum length of the internal buffer that is
505
+ * required to be full before flushing.
506
+ */
507
+ minLength?: number | undefined;
508
+ /**
509
+ * Ensure directory for `dest` file exists when true.
510
+ * @default false
511
+ */
512
+ mkdir?: boolean | undefined;
513
+ /**
514
+ * Specify the creating file mode (see `fs.open()`).
515
+ */
516
+ mode?: number | string | undefined;
517
+ /**
518
+ * Calls flush every `periodicFlush` milliseconds.
519
+ */
520
+ periodicFlush?: number | undefined;
521
+ /**
522
+ * A function that will be called when `write()`,
523
+ * `writeSync()`, or `flushSync()` encounters an `EAGAIN` or `EBUSY` error.
524
+ * If the return value is `true` the operation will be retried, otherwise it
525
+ * will bubble the error. The `err` is the error that caused this function to
526
+ * be called, `writeBufferLen` is the length of the buffer that was written,
527
+ * and `remainingBufferLen` is the length of the remaining buffer that the
528
+ * stream did not try to write.
529
+ */
530
+ retryEAGAIN?: ((err: Error | null, writeBufferLen: number, remainingBufferLen: number) => boolean) | undefined;
531
+ /**
532
+ * Perform writes synchronously.
533
+ */
534
+ sync?: boolean | undefined;
535
+ }
536
+ /**
537
+ * An optimized UTF-8 stream writer that allows for flushing all the internal
538
+ * buffering on demand. It handles `EAGAIN` errors correctly, allowing for
539
+ * customization, for example, by dropping content if the disk is busy.
540
+ * @since v24.6.0
541
+ * @experimental
542
+ */
543
+ export class Utf8Stream extends EventEmitter {
544
+ constructor(options: Utf8StreamOptions);
545
+ /**
546
+ * Whether the stream is appending to the file or truncating it.
547
+ */
548
+ readonly append: boolean;
549
+ /**
550
+ * The type of data that can be written to the stream. Supported
551
+ * values are `'utf8'` or `'buffer'`.
552
+ * @default 'utf8'
553
+ */
554
+ readonly contentMode: "utf8" | "buffer";
555
+ /**
556
+ * Close the stream immediately, without flushing the internal buffer.
557
+ */
558
+ destroy(): void;
559
+ /**
560
+ * Close the stream gracefully, flushing the internal buffer before closing.
561
+ */
562
+ end(): void;
563
+ /**
564
+ * The file descriptor that is being written to.
565
+ */
566
+ readonly fd: number;
567
+ /**
568
+ * The file that is being written to.
569
+ */
570
+ readonly file: string;
571
+ /**
572
+ * Writes the current buffer to the file if a write was not in progress. Do
573
+ * nothing if `minLength` is zero or if it is already writing.
574
+ */
575
+ flush(callback: (err: Error | null) => void): void;
576
+ /**
577
+ * Flushes the buffered data synchronously. This is a costly operation.
578
+ */
579
+ flushSync(): void;
580
+ /**
581
+ * Whether the stream is performing a `fs.fsyncSync()` after every
582
+ * write operation.
583
+ */
584
+ readonly fsync: boolean;
585
+ /**
586
+ * The maximum length of the internal buffer. If a write
587
+ * operation would cause the buffer to exceed `maxLength`, the data written is
588
+ * dropped and a drop event is emitted with the dropped data.
589
+ */
590
+ readonly maxLength: number;
591
+ /**
592
+ * The minimum length of the internal buffer that is required to be
593
+ * full before flushing.
594
+ */
595
+ readonly minLength: number;
596
+ /**
597
+ * Whether the stream should ensure that the directory for the
598
+ * `dest` file exists. If `true`, it will create the directory if it does not
599
+ * exist.
600
+ * @default false
601
+ */
602
+ readonly mkdir: boolean;
603
+ /**
604
+ * The mode of the file that is being written to.
605
+ */
606
+ readonly mode: number | string;
607
+ /**
608
+ * The number of milliseconds between flushes. If set to `0`, no
609
+ * periodic flushes will be performed.
610
+ */
611
+ readonly periodicFlush: number;
612
+ /**
613
+ * Reopen the file in place, useful for log rotation.
614
+ * @param file A path to a file to be written to (mode
615
+ * controlled by the append option).
616
+ */
617
+ reopen(file: PathLike): void;
618
+ /**
619
+ * Whether the stream is writing synchronously or asynchronously.
620
+ */
621
+ readonly sync: boolean;
622
+ /**
623
+ * When the `options.contentMode` is set to `'utf8'` when the stream is created,
624
+ * the `data` argument must be a string. If the `contentMode` is set to `'buffer'`,
625
+ * the `data` argument must be a `Buffer`.
626
+ * @param data The data to write.
627
+ */
628
+ write(data: string | Buffer): boolean;
629
+ /**
630
+ * Whether the stream is currently writing data to the file.
631
+ */
632
+ readonly writing: boolean;
633
+ /**
634
+ * Calls `utf8Stream.destroy()`.
635
+ */
636
+ [Symbol.dispose](): void;
637
+ /**
638
+ * events.EventEmitter
639
+ * 1. change
640
+ * 2. close
641
+ * 3. error
642
+ */
643
+ addListener(event: "close", listener: () => void): this;
644
+ addListener(event: "drain", listener: () => void): this;
645
+ addListener(event: "drop", listener: (data: string | Buffer) => void): this;
646
+ addListener(event: "error", listener: (error: Error) => void): this;
647
+ addListener(event: "finish", listener: () => void): this;
648
+ addListener(event: "ready", listener: () => void): this;
649
+ addListener(event: "write", listener: (n: number) => void): this;
650
+ addListener(event: string, listener: (...args: any[]) => void): this;
651
+ on(event: "close", listener: () => void): this;
652
+ on(event: "drain", listener: () => void): this;
653
+ on(event: "drop", listener: (data: string | Buffer) => void): this;
654
+ on(event: "error", listener: (error: Error) => void): this;
655
+ on(event: "finish", listener: () => void): this;
656
+ on(event: "ready", listener: () => void): this;
657
+ on(event: "write", listener: (n: number) => void): this;
658
+ on(event: string, listener: (...args: any[]) => void): this;
659
+ once(event: "close", listener: () => void): this;
660
+ once(event: "drain", listener: () => void): this;
661
+ once(event: "drop", listener: (data: string | Buffer) => void): this;
662
+ once(event: "error", listener: (error: Error) => void): this;
663
+ once(event: "finish", listener: () => void): this;
664
+ once(event: "ready", listener: () => void): this;
665
+ once(event: "write", listener: (n: number) => void): this;
666
+ once(event: string, listener: (...args: any[]) => void): this;
667
+ prependListener(event: "close", listener: () => void): this;
668
+ prependListener(event: "drain", listener: () => void): this;
669
+ prependListener(event: "drop", listener: (data: string | Buffer) => void): this;
670
+ prependListener(event: "error", listener: (error: Error) => void): this;
671
+ prependListener(event: "finish", listener: () => void): this;
672
+ prependListener(event: "ready", listener: () => void): this;
673
+ prependListener(event: "write", listener: (n: number) => void): this;
674
+ prependListener(event: string, listener: (...args: any[]) => void): this;
675
+ prependOnceListener(event: "close", listener: () => void): this;
676
+ prependOnceListener(event: "drain", listener: () => void): this;
677
+ prependOnceListener(event: "drop", listener: (data: string | Buffer) => void): this;
678
+ prependOnceListener(event: "error", listener: (error: Error) => void): this;
679
+ prependOnceListener(event: "finish", listener: () => void): this;
680
+ prependOnceListener(event: "ready", listener: () => void): this;
681
+ prependOnceListener(event: "write", listener: (n: number) => void): this;
682
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
683
+ }
452
684
 
453
685
  /**
454
686
  * The Keys are events of the ReadStream and the values are the functions that are called when the event is emitted.
@@ -1855,7 +2087,7 @@ declare module "fs" {
1855
2087
  * The `fs.mkdtemp()` method will append the six randomly selected characters
1856
2088
  * directly to the `prefix` string. For instance, given a directory `/tmp`, if the
1857
2089
  * intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator
1858
- * (`import { sep } from 'node:node:path'`).
2090
+ * (`import { sep } from 'node:path'`).
1859
2091
  *
1860
2092
  * ```js
1861
2093
  * import { tmpdir } from 'node:os';
@@ -1961,6 +2193,39 @@ declare module "fs" {
1961
2193
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1962
2194
  */
1963
2195
  export function mkdtempSync(prefix: string, options?: EncodingOption): string | NonSharedBuffer;
2196
+ export interface DisposableTempDir extends AsyncDisposable {
2197
+ /**
2198
+ * The path of the created directory.
2199
+ */
2200
+ path: string;
2201
+ /**
2202
+ * A function which removes the created directory.
2203
+ */
2204
+ remove(): Promise<void>;
2205
+ /**
2206
+ * The same as `remove`.
2207
+ */
2208
+ [Symbol.asyncDispose](): Promise<void>;
2209
+ }
2210
+ /**
2211
+ * Returns a disposable object whose `path` property holds the created directory
2212
+ * path. When the object is disposed, the directory and its contents will be
2213
+ * removed if it still exists. If the directory cannot be deleted, disposal will
2214
+ * throw an error. The object has a `remove()` method which will perform the same
2215
+ * task.
2216
+ *
2217
+ * <!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
2218
+ *
2219
+ * For detailed information, see the documentation of `fs.mkdtemp()`.
2220
+ *
2221
+ * There is no callback-based version of this API because it is designed for use
2222
+ * with the `using` syntax.
2223
+ *
2224
+ * The optional `options` argument can be a string specifying an encoding, or an
2225
+ * object with an `encoding` property specifying the character encoding to use.
2226
+ * @since v24.4.0
2227
+ */
2228
+ export function mkdtempDisposableSync(prefix: string, options?: EncodingOption): DisposableTempDir;
1964
2229
  /**
1965
2230
  * Reads the contents of a directory. The callback gets two arguments `(err, files)` where `files` is an array of the names of the files in the directory excluding `'.'` and `'..'`.
1966
2231
  *
@@ -2663,7 +2928,7 @@ declare module "fs" {
2663
2928
  buffer: TBuffer,
2664
2929
  offset: number,
2665
2930
  length: number,
2666
- position: number | null,
2931
+ position: ReadPosition | null,
2667
2932
  ): Promise<{
2668
2933
  bytesRead: number;
2669
2934
  buffer: TBuffer;
@@ -3208,7 +3473,7 @@ declare module "fs" {
3208
3473
  * stat object:
3209
3474
  *
3210
3475
  * ```js
3211
- * import { watchFile } from 'fs';
3476
+ * import { watchFile } from 'node:fs';
3212
3477
  *
3213
3478
  * watchFile('message.text', (curr, prev) => {
3214
3479
  * console.log(`the current mtime is: ${curr.mtime}`);
@@ -3334,6 +3599,12 @@ declare module "fs" {
3334
3599
  persistent?: boolean | undefined;
3335
3600
  recursive?: boolean | undefined;
3336
3601
  }
3602
+ export interface WatchOptionsWithBufferEncoding extends WatchOptions {
3603
+ encoding: "buffer";
3604
+ }
3605
+ export interface WatchOptionsWithStringEncoding extends WatchOptions {
3606
+ encoding?: BufferEncoding | undefined;
3607
+ }
3337
3608
  export type WatchEventType = "rename" | "change";
3338
3609
  export type WatchListener<T> = (event: WatchEventType, filename: T | null) => void;
3339
3610
  export type StatsListener = (curr: Stats, prev: Stats) => void;
@@ -3360,44 +3631,20 @@ declare module "fs" {
3360
3631
  */
3361
3632
  export function watch(
3362
3633
  filename: PathLike,
3363
- options:
3364
- | (WatchOptions & {
3365
- encoding: "buffer";
3366
- })
3367
- | "buffer",
3368
- listener?: WatchListener<NonSharedBuffer>,
3634
+ options?: WatchOptionsWithStringEncoding | BufferEncoding | null,
3635
+ listener?: WatchListener<string>,
3369
3636
  ): FSWatcher;
3370
- /**
3371
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3372
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3373
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
3374
- * If `encoding` is not supplied, the default of `'utf8'` is used.
3375
- * If `persistent` is not supplied, the default of `true` is used.
3376
- * If `recursive` is not supplied, the default of `false` is used.
3377
- */
3378
3637
  export function watch(
3379
3638
  filename: PathLike,
3380
- options?: WatchOptions | BufferEncoding | null,
3381
- listener?: WatchListener<string>,
3639
+ options: WatchOptionsWithBufferEncoding | "buffer",
3640
+ listener: WatchListener<NonSharedBuffer>,
3382
3641
  ): FSWatcher;
3383
- /**
3384
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3385
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3386
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
3387
- * If `encoding` is not supplied, the default of `'utf8'` is used.
3388
- * If `persistent` is not supplied, the default of `true` is used.
3389
- * If `recursive` is not supplied, the default of `false` is used.
3390
- */
3391
3642
  export function watch(
3392
3643
  filename: PathLike,
3393
- options: WatchOptions | string,
3394
- listener?: WatchListener<string | NonSharedBuffer>,
3644
+ options: WatchOptions | BufferEncoding | "buffer" | null,
3645
+ listener: WatchListener<string | NonSharedBuffer>,
3395
3646
  ): FSWatcher;
3396
- /**
3397
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3398
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3399
- */
3400
- export function watch(filename: PathLike, listener?: WatchListener<string>): FSWatcher;
3647
+ export function watch(filename: PathLike, listener: WatchListener<string>): FSWatcher;
3401
3648
  /**
3402
3649
  * Test whether or not the given path exists by checking with the file system.
3403
3650
  * Then call the `callback` argument with either true or false:
@@ -3897,9 +4144,6 @@ declare module "fs" {
3897
4144
  flush?: boolean | undefined;
3898
4145
  }
3899
4146
  /**
3900
- * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream
3901
- * returned by this method has a default `highWaterMark` of 64 KiB.
3902
- *
3903
4147
  * `options` can include `start` and `end` values to read a range of bytes from
3904
4148
  * the file instead of the entire file. Both `start` and `end` are inclusive and
3905
4149
  * start counting at 0, allowed values are in the
@@ -4214,7 +4458,6 @@ declare module "fs" {
4214
4458
  * blob.stream();
4215
4459
  * ```
4216
4460
  * @since v19.8.0
4217
- * @experimental
4218
4461
  */
4219
4462
  export function openAsBlob(path: PathLike, options?: OpenAsBlobOptions): Promise<Blob>;
4220
4463
 
@@ -4369,6 +4612,102 @@ declare module "fs" {
4369
4612
  * @param dest destination path to copy to.
4370
4613
  */
4371
4614
  export function cpSync(source: string | URL, destination: string | URL, opts?: CopySyncOptions): void;
4615
+
4616
+ // TODO: collapse
4617
+ interface _GlobOptions<T extends Dirent | string> {
4618
+ /**
4619
+ * Current working directory.
4620
+ * @default process.cwd()
4621
+ */
4622
+ cwd?: string | URL | undefined;
4623
+ /**
4624
+ * `true` if the glob should return paths as `Dirent`s, `false` otherwise.
4625
+ * @default false
4626
+ * @since v22.2.0
4627
+ */
4628
+ withFileTypes?: boolean | undefined;
4629
+ /**
4630
+ * Function to filter out files/directories or a
4631
+ * list of glob patterns to be excluded. If a function is provided, return
4632
+ * `true` to exclude the item, `false` to include it.
4633
+ * If a string array is provided, each string should be a glob pattern that
4634
+ * specifies paths to exclude. Note: Negation patterns (e.g., '!foo.js') are
4635
+ * not supported.
4636
+ * @default undefined
4637
+ */
4638
+ exclude?: ((fileName: T) => boolean) | readonly string[] | undefined;
4639
+ }
4640
+ export interface GlobOptions extends _GlobOptions<Dirent | string> {}
4641
+ export interface GlobOptionsWithFileTypes extends _GlobOptions<Dirent> {
4642
+ withFileTypes: true;
4643
+ }
4644
+ export interface GlobOptionsWithoutFileTypes extends _GlobOptions<string> {
4645
+ withFileTypes?: false | undefined;
4646
+ }
4647
+
4648
+ /**
4649
+ * Retrieves the files matching the specified pattern.
4650
+ *
4651
+ * ```js
4652
+ * import { glob } from 'node:fs';
4653
+ *
4654
+ * glob('*.js', (err, matches) => {
4655
+ * if (err) throw err;
4656
+ * console.log(matches);
4657
+ * });
4658
+ * ```
4659
+ * @since v22.0.0
4660
+ */
4661
+ export function glob(
4662
+ pattern: string | readonly string[],
4663
+ callback: (err: NodeJS.ErrnoException | null, matches: string[]) => void,
4664
+ ): void;
4665
+ export function glob(
4666
+ pattern: string | readonly string[],
4667
+ options: GlobOptionsWithFileTypes,
4668
+ callback: (
4669
+ err: NodeJS.ErrnoException | null,
4670
+ matches: Dirent[],
4671
+ ) => void,
4672
+ ): void;
4673
+ export function glob(
4674
+ pattern: string | readonly string[],
4675
+ options: GlobOptionsWithoutFileTypes,
4676
+ callback: (
4677
+ err: NodeJS.ErrnoException | null,
4678
+ matches: string[],
4679
+ ) => void,
4680
+ ): void;
4681
+ export function glob(
4682
+ pattern: string | readonly string[],
4683
+ options: GlobOptions,
4684
+ callback: (
4685
+ err: NodeJS.ErrnoException | null,
4686
+ matches: Dirent[] | string[],
4687
+ ) => void,
4688
+ ): void;
4689
+ /**
4690
+ * ```js
4691
+ * import { globSync } from 'node:fs';
4692
+ *
4693
+ * console.log(globSync('*.js'));
4694
+ * ```
4695
+ * @since v22.0.0
4696
+ * @returns paths of files that match the pattern.
4697
+ */
4698
+ export function globSync(pattern: string | readonly string[]): string[];
4699
+ export function globSync(
4700
+ pattern: string | readonly string[],
4701
+ options: GlobOptionsWithFileTypes,
4702
+ ): Dirent[];
4703
+ export function globSync(
4704
+ pattern: string | readonly string[],
4705
+ options: GlobOptionsWithoutFileTypes,
4706
+ ): string[];
4707
+ export function globSync(
4708
+ pattern: string | readonly string[],
4709
+ options: GlobOptions,
4710
+ ): Dirent[] | string[];
4372
4711
  }
4373
4712
  declare module "node:fs" {
4374
4713
  export * from "fs";
@@ -159,14 +159,12 @@ declare namespace NodeJS {
159
159
  }
160
160
 
161
161
  /** An iterable iterator returned by the Node.js API. */
162
- // Default TReturn/TNext in v20 is `any`, for compatibility with the previously-used IterableIterator.
163
- interface Iterator<T, TReturn = any, TNext = any> extends IteratorObject<T, TReturn, TNext> {
162
+ interface Iterator<T, TReturn = undefined, TNext = any> extends IteratorObject<T, TReturn, TNext> {
164
163
  [Symbol.iterator](): NodeJS.Iterator<T, TReturn, TNext>;
165
164
  }
166
165
 
167
166
  /** An async iterable iterator returned by the Node.js API. */
168
- // Default TReturn/TNext in v20 is `any`, for compatibility with the previously-used AsyncIterableIterator.
169
- interface AsyncIterator<T, TReturn = any, TNext = any> extends AsyncIteratorObject<T, TReturn, TNext> {
167
+ interface AsyncIterator<T, TReturn = undefined, TNext = any> extends AsyncIteratorObject<T, TReturn, TNext> {
170
168
  [Symbol.asyncIterator](): NodeJS.AsyncIterator<T, TReturn, TNext>;
171
169
  }
172
170
  }
@@ -12,6 +12,7 @@ declare global {
12
12
  | Int32Array<TArrayBuffer>
13
13
  | BigUint64Array<TArrayBuffer>
14
14
  | BigInt64Array<TArrayBuffer>
15
+ | Float16Array<TArrayBuffer>
15
16
  | Float32Array<TArrayBuffer>
16
17
  | Float64Array<TArrayBuffer>;
17
18
  type ArrayBufferView<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> =
@@ -20,6 +21,7 @@ declare global {
20
21
 
21
22
  // The following aliases are required to allow use of non-shared ArrayBufferViews in @types/node
22
23
  // while maintaining compatibility with TS <=5.6.
24
+ // TODO: remove once @types/node no longer supports TS 5.6, and replace with native types.
23
25
  type NonSharedUint8Array = Uint8Array<ArrayBuffer>;
24
26
  type NonSharedUint8ClampedArray = Uint8ClampedArray<ArrayBuffer>;
25
27
  type NonSharedUint16Array = Uint16Array<ArrayBuffer>;
@@ -29,6 +31,7 @@ declare global {
29
31
  type NonSharedInt32Array = Int32Array<ArrayBuffer>;
30
32
  type NonSharedBigUint64Array = BigUint64Array<ArrayBuffer>;
31
33
  type NonSharedBigInt64Array = BigInt64Array<ArrayBuffer>;
34
+ type NonSharedFloat16Array = Float16Array<ArrayBuffer>;
32
35
  type NonSharedFloat32Array = Float32Array<ArrayBuffer>;
33
36
  type NonSharedFloat64Array = Float64Array<ArrayBuffer>;
34
37
  type NonSharedDataView = DataView<ArrayBuffer>;