@types/node 13.13.50 → 14.0.1

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 (61) hide show
  1. {node v13.13 → node}/LICENSE +0 -0
  2. node/README.md +16 -0
  3. node v13.13/ts3.6/assert.d.ts → node/assert.d.ts +8 -27
  4. node v13.13/async_hooks.d.ts → node/async_hooks.d.ts +1 -29
  5. node/base.d.ts +41 -0
  6. {node v13.13 → node}/buffer.d.ts +0 -0
  7. node v13.13/child_process.d.ts → node/child_process.d.ts +28 -28
  8. {node v13.13 → node}/cluster.d.ts +0 -0
  9. {node v13.13 → node}/console.d.ts +0 -0
  10. {node v13.13 → node}/constants.d.ts +0 -0
  11. node v13.13/crypto.d.ts → node/crypto.d.ts +83 -287
  12. node v13.13/dgram.d.ts → node/dgram.d.ts +3 -3
  13. {node v13.13 → node}/dns.d.ts +0 -0
  14. node v13.13/domain.d.ts → node/domain.d.ts +2 -2
  15. node v13.13/events.d.ts → node/events.d.ts +17 -22
  16. node/fs/promises.d.ts +539 -0
  17. node v13.13/fs.d.ts → node/fs.d.ts +272 -820
  18. node v13.13/globals.d.ts → node/globals.d.ts +15 -94
  19. node v13.13/http.d.ts → node/http.d.ts +4 -11
  20. node v13.13/http2.d.ts → node/http2.d.ts +6 -6
  21. {node v13.13 → node}/https.d.ts +0 -0
  22. node v13.13/index.d.ts → node/index.d.ts +44 -5
  23. node v13.13/inspector.d.ts → node/inspector.d.ts +7 -0
  24. node v13.13/module.d.ts → node/module.d.ts +0 -6
  25. node v13.13/net.d.ts → node/net.d.ts +3 -3
  26. node v13.13/os.d.ts → node/os.d.ts +1 -1
  27. node v13.13/package.json → node/package.json +35 -10
  28. {node v13.13 → node}/path.d.ts +0 -0
  29. node v13.13/perf_hooks.d.ts → node/perf_hooks.d.ts +74 -8
  30. {node v13.13 → node}/process.d.ts +0 -0
  31. node/punycode.d.ts +12 -0
  32. {node v13.13 → node}/querystring.d.ts +0 -0
  33. {node v13.13 → node}/readline.d.ts +0 -0
  34. node v13.13/repl.d.ts → node/repl.d.ts +2 -10
  35. node v13.13/stream.d.ts → node/stream.d.ts +27 -33
  36. node v13.13/string_decoder.d.ts → node/string_decoder.d.ts +1 -1
  37. {node v13.13 → node}/timers.d.ts +0 -0
  38. node v13.13/tls.d.ts → node/tls.d.ts +2 -2
  39. {node v13.13 → node}/trace_events.d.ts +0 -0
  40. node/ts3.2/base.d.ts +22 -0
  41. node/ts3.2/fs.d.ts +33 -0
  42. node/ts3.2/globals.d.ts +19 -0
  43. node/ts3.2/index.d.ts +8 -0
  44. node/ts3.2/util.d.ts +9 -0
  45. node/ts3.5/base.d.ts +20 -0
  46. node v13.13/ts3.6/index.d.ts → node/ts3.5/index.d.ts +4 -2
  47. node v13.13/wasi.d.ts → node/ts3.5/wasi.d.ts +1 -4
  48. node v13.13/assert.d.ts → node/ts3.7/assert.d.ts +9 -54
  49. node v13.13/base.d.ts → node/ts3.7/base.d.ts +2 -1
  50. node/ts3.7/index.d.ts +5 -0
  51. {node v13.13 → node}/tty.d.ts +0 -0
  52. node v13.13/url.d.ts → node/url.d.ts +1 -7
  53. node v13.13/util.d.ts → node/util.d.ts +14 -30
  54. {node v13.13 → node}/v8.d.ts +0 -0
  55. node v13.13/vm.d.ts → node/vm.d.ts +1 -3
  56. node v13.13/worker_threads.d.ts → node/worker_threads.d.ts +3 -21
  57. node v13.13/zlib.d.ts → node/zlib.d.ts +0 -1
  58. node v13.13/README.md +0 -16
  59. node v13.13/globals.global.d.ts +0 -1
  60. node v13.13/punycode.d.ts +0 -68
  61. node v13.13/ts3.6/base.d.ts +0 -60
@@ -2,15 +2,27 @@ declare module "fs" {
2
2
  import * as stream from "stream";
3
3
  import * as events from "events";
4
4
  import { URL } from "url";
5
+ import * as promises from 'fs/promises';
5
6
 
7
+ export { promises };
6
8
  /**
7
9
  * Valid types for path values in "fs".
8
10
  */
9
- type PathLike = string | Buffer | URL;
11
+ export type PathLike = string | Buffer | URL;
10
12
 
11
- type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
13
+ export type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
12
14
 
13
- interface StatsBase<T> {
15
+ export type BufferEncodingOption = 'buffer' | { encoding: 'buffer' };
16
+
17
+ export interface BaseEncodingOptions {
18
+ encoding?: BufferEncoding | null;
19
+ }
20
+
21
+ export type OpenMode = number | string;
22
+
23
+ export type Mode = number | string;
24
+
25
+ export interface StatsBase<T> {
14
26
  isFile(): boolean;
15
27
  isDirectory(): boolean;
16
28
  isBlockDevice(): boolean;
@@ -39,13 +51,13 @@ declare module "fs" {
39
51
  birthtime: Date;
40
52
  }
41
53
 
42
- interface Stats extends StatsBase<number> {
54
+ export interface Stats extends StatsBase<number> {
43
55
  }
44
56
 
45
- class Stats {
57
+ export class Stats {
46
58
  }
47
59
 
48
- class Dirent {
60
+ export class Dirent {
49
61
  isFile(): boolean;
50
62
  isDirectory(): boolean;
51
63
  isBlockDevice(): boolean;
@@ -59,7 +71,7 @@ declare module "fs" {
59
71
  /**
60
72
  * A class representing a directory stream.
61
73
  */
62
- class Dir {
74
+ export class Dir {
63
75
  readonly path: string;
64
76
 
65
77
  /**
@@ -96,7 +108,7 @@ declare module "fs" {
96
108
  readSync(): Dirent;
97
109
  }
98
110
 
99
- interface FSWatcher extends events.EventEmitter {
111
+ export interface FSWatcher extends events.EventEmitter {
100
112
  close(): void;
101
113
 
102
114
  /**
@@ -130,7 +142,7 @@ declare module "fs" {
130
142
  prependOnceListener(event: "close", listener: () => void): this;
131
143
  }
132
144
 
133
- class ReadStream extends stream.Readable {
145
+ export class ReadStream extends stream.Readable {
134
146
  close(): void;
135
147
  bytesRead: number;
136
148
  path: string | Buffer;
@@ -198,7 +210,7 @@ declare module "fs" {
198
210
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
199
211
  }
200
212
 
201
- class WriteStream extends stream.Writable {
213
+ export class WriteStream extends stream.Writable {
202
214
  close(): void;
203
215
  bytesWritten: number;
204
216
  path: string | Buffer;
@@ -268,10 +280,10 @@ declare module "fs" {
268
280
  * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
269
281
  * URL support is _experimental_.
270
282
  */
271
- function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
283
+ export function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
272
284
 
273
285
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
274
- namespace rename {
286
+ export namespace rename {
275
287
  /**
276
288
  * Asynchronous rename(2) - Change the name or location of a file or directory.
277
289
  * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -289,24 +301,24 @@ declare module "fs" {
289
301
  * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
290
302
  * URL support is _experimental_.
291
303
  */
292
- function renameSync(oldPath: PathLike, newPath: PathLike): void;
304
+ export function renameSync(oldPath: PathLike, newPath: PathLike): void;
293
305
 
294
306
  /**
295
307
  * Asynchronous truncate(2) - Truncate a file to a specified length.
296
308
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
297
309
  * @param len If not specified, defaults to `0`.
298
310
  */
299
- function truncate(path: PathLike, len: number | undefined | null, callback: NoParamCallback): void;
311
+ export function truncate(path: PathLike, len: number | undefined | null, callback: NoParamCallback): void;
300
312
 
301
313
  /**
302
314
  * Asynchronous truncate(2) - Truncate a file to a specified length.
303
315
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
304
316
  * URL support is _experimental_.
305
317
  */
306
- function truncate(path: PathLike, callback: NoParamCallback): void;
318
+ export function truncate(path: PathLike, callback: NoParamCallback): void;
307
319
 
308
320
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
309
- namespace truncate {
321
+ export namespace truncate {
310
322
  /**
311
323
  * Asynchronous truncate(2) - Truncate a file to a specified length.
312
324
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -320,23 +332,23 @@ declare module "fs" {
320
332
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
321
333
  * @param len If not specified, defaults to `0`.
322
334
  */
323
- function truncateSync(path: PathLike, len?: number | null): void;
335
+ export function truncateSync(path: PathLike, len?: number | null): void;
324
336
 
325
337
  /**
326
338
  * Asynchronous ftruncate(2) - Truncate a file to a specified length.
327
339
  * @param fd A file descriptor.
328
340
  * @param len If not specified, defaults to `0`.
329
341
  */
330
- function ftruncate(fd: number, len: number | undefined | null, callback: NoParamCallback): void;
342
+ export function ftruncate(fd: number, len: number | undefined | null, callback: NoParamCallback): void;
331
343
 
332
344
  /**
333
345
  * Asynchronous ftruncate(2) - Truncate a file to a specified length.
334
346
  * @param fd A file descriptor.
335
347
  */
336
- function ftruncate(fd: number, callback: NoParamCallback): void;
348
+ export function ftruncate(fd: number, callback: NoParamCallback): void;
337
349
 
338
350
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
339
- namespace ftruncate {
351
+ export namespace ftruncate {
340
352
  /**
341
353
  * Asynchronous ftruncate(2) - Truncate a file to a specified length.
342
354
  * @param fd A file descriptor.
@@ -350,16 +362,16 @@ declare module "fs" {
350
362
  * @param fd A file descriptor.
351
363
  * @param len If not specified, defaults to `0`.
352
364
  */
353
- function ftruncateSync(fd: number, len?: number | null): void;
365
+ export function ftruncateSync(fd: number, len?: number | null): void;
354
366
 
355
367
  /**
356
368
  * Asynchronous chown(2) - Change ownership of a file.
357
369
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
358
370
  */
359
- function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
371
+ export function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
360
372
 
361
373
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
362
- namespace chown {
374
+ export namespace chown {
363
375
  /**
364
376
  * Asynchronous chown(2) - Change ownership of a file.
365
377
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -371,16 +383,16 @@ declare module "fs" {
371
383
  * Synchronous chown(2) - Change ownership of a file.
372
384
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
373
385
  */
374
- function chownSync(path: PathLike, uid: number, gid: number): void;
386
+ export function chownSync(path: PathLike, uid: number, gid: number): void;
375
387
 
376
388
  /**
377
389
  * Asynchronous fchown(2) - Change ownership of a file.
378
390
  * @param fd A file descriptor.
379
391
  */
380
- function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void;
392
+ export function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void;
381
393
 
382
394
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
383
- namespace fchown {
395
+ export namespace fchown {
384
396
  /**
385
397
  * Asynchronous fchown(2) - Change ownership of a file.
386
398
  * @param fd A file descriptor.
@@ -392,16 +404,16 @@ declare module "fs" {
392
404
  * Synchronous fchown(2) - Change ownership of a file.
393
405
  * @param fd A file descriptor.
394
406
  */
395
- function fchownSync(fd: number, uid: number, gid: number): void;
407
+ export function fchownSync(fd: number, uid: number, gid: number): void;
396
408
 
397
409
  /**
398
410
  * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
399
411
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
400
412
  */
401
- function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
413
+ export function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
402
414
 
403
415
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
404
- namespace lchown {
416
+ export namespace lchown {
405
417
  /**
406
418
  * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
407
419
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -413,23 +425,23 @@ declare module "fs" {
413
425
  * Synchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
414
426
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
415
427
  */
416
- function lchownSync(path: PathLike, uid: number, gid: number): void;
428
+ export function lchownSync(path: PathLike, uid: number, gid: number): void;
417
429
 
418
430
  /**
419
431
  * Asynchronous chmod(2) - Change permissions of a file.
420
432
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
421
433
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
422
434
  */
423
- function chmod(path: PathLike, mode: string | number, callback: NoParamCallback): void;
435
+ export function chmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;
424
436
 
425
437
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
426
- namespace chmod {
438
+ export namespace chmod {
427
439
  /**
428
440
  * Asynchronous chmod(2) - Change permissions of a file.
429
441
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
430
442
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
431
443
  */
432
- function __promisify__(path: PathLike, mode: string | number): Promise<void>;
444
+ function __promisify__(path: PathLike, mode: Mode): Promise<void>;
433
445
  }
434
446
 
435
447
  /**
@@ -437,23 +449,23 @@ declare module "fs" {
437
449
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
438
450
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
439
451
  */
440
- function chmodSync(path: PathLike, mode: string | number): void;
452
+ export function chmodSync(path: PathLike, mode: Mode): void;
441
453
 
442
454
  /**
443
455
  * Asynchronous fchmod(2) - Change permissions of a file.
444
456
  * @param fd A file descriptor.
445
457
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
446
458
  */
447
- function fchmod(fd: number, mode: string | number, callback: NoParamCallback): void;
459
+ export function fchmod(fd: number, mode: Mode, callback: NoParamCallback): void;
448
460
 
449
461
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
450
- namespace fchmod {
462
+ export namespace fchmod {
451
463
  /**
452
464
  * Asynchronous fchmod(2) - Change permissions of a file.
453
465
  * @param fd A file descriptor.
454
466
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
455
467
  */
456
- function __promisify__(fd: number, mode: string | number): Promise<void>;
468
+ function __promisify__(fd: number, mode: Mode): Promise<void>;
457
469
  }
458
470
 
459
471
  /**
@@ -461,23 +473,23 @@ declare module "fs" {
461
473
  * @param fd A file descriptor.
462
474
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
463
475
  */
464
- function fchmodSync(fd: number, mode: string | number): void;
476
+ export function fchmodSync(fd: number, mode: Mode): void;
465
477
 
466
478
  /**
467
479
  * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
468
480
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
469
481
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
470
482
  */
471
- function lchmod(path: PathLike, mode: string | number, callback: NoParamCallback): void;
483
+ export function lchmod(path: PathLike, mode: Mode, callback: NoParamCallback): void;
472
484
 
473
485
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
474
- namespace lchmod {
486
+ export namespace lchmod {
475
487
  /**
476
488
  * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
477
489
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
478
490
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
479
491
  */
480
- function __promisify__(path: PathLike, mode: string | number): Promise<void>;
492
+ function __promisify__(path: PathLike, mode: Mode): Promise<void>;
481
493
  }
482
494
 
483
495
  /**
@@ -485,101 +497,80 @@ declare module "fs" {
485
497
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
486
498
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
487
499
  */
488
- function lchmodSync(path: PathLike, mode: string | number): void;
500
+ export function lchmodSync(path: PathLike, mode: Mode): void;
489
501
 
490
502
  /**
491
503
  * Asynchronous stat(2) - Get file status.
492
504
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
493
505
  */
494
- function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
495
- function stat(path: PathLike, options: StatOptions & { bigint?: false } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
496
- function stat(path: PathLike, options: StatOptions & { bigint: true }, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void;
497
- function stat(path: PathLike, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
506
+ export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
498
507
 
499
508
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
500
- namespace stat {
509
+ export namespace stat {
501
510
  /**
502
511
  * Asynchronous stat(2) - Get file status.
503
512
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
504
513
  */
505
- function __promisify__(path: PathLike, options?: StatOptions & { bigint?: false }): Promise<Stats>;
506
- function __promisify__(path: PathLike, options: StatOptions & { bigint: true }): Promise<BigIntStats>;
507
- function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
514
+ function __promisify__(path: PathLike): Promise<Stats>;
508
515
  }
509
516
 
510
517
  /**
511
518
  * Synchronous stat(2) - Get file status.
512
519
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
513
520
  */
514
- function statSync(path: PathLike, options?: StatOptions & { bigint?: false }): Stats;
515
- function statSync(path: PathLike, options: StatOptions & { bigint: true }): BigIntStats;
516
- function statSync(path: PathLike, options?: StatOptions): Stats | BigIntStats;
521
+ export function statSync(path: PathLike): Stats;
517
522
 
518
523
  /**
519
524
  * Asynchronous fstat(2) - Get file status.
520
525
  * @param fd A file descriptor.
521
526
  */
522
- function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
523
- function fstat(fd: number, options: StatOptions & { bigint?: false } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
524
- function fstat(fd: number, options: StatOptions & { bigint: true }, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void;
525
- function fstat(fd: number, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
527
+ export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
526
528
 
527
529
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
528
- namespace fstat {
530
+ export namespace fstat {
529
531
  /**
530
532
  * Asynchronous fstat(2) - Get file status.
531
533
  * @param fd A file descriptor.
532
534
  */
533
- function __promisify__(fd: number, options?: StatOptions & { bigint?: false }): Promise<Stats>;
534
- function __promisify__(fd: number, options: StatOptions & { bigint: true }): Promise<BigIntStats>;
535
- function __promisify__(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>;
535
+ function __promisify__(fd: number): Promise<Stats>;
536
536
  }
537
537
 
538
538
  /**
539
539
  * Synchronous fstat(2) - Get file status.
540
540
  * @param fd A file descriptor.
541
541
  */
542
- function fstatSync(fd: number, options?: StatOptions & { bigint?: false }): Stats;
543
- function fstatSync(fd: number, options: StatOptions & { bigint: true }): BigIntStats;
544
- function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats;
542
+ export function fstatSync(fd: number): Stats;
545
543
 
546
544
  /**
547
545
  * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
548
546
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
549
547
  */
550
- function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
551
- function lstat(path: PathLike, options: StatOptions & { bigint?: false } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
552
- function lstat(path: PathLike, options: StatOptions & { bigint: true }, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void;
553
- function lstat(path: PathLike, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
548
+ export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
554
549
 
555
550
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
556
- namespace lstat {
551
+ export namespace lstat {
557
552
  /**
558
553
  * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
559
554
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
560
555
  */
561
- function __promisify__(path: PathLike, options?: StatOptions & { bigint?: false }): Promise<Stats>;
562
- function __promisify__(path: PathLike, options: StatOptions & { bigint: true }): Promise<BigIntStats>;
563
- function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
556
+ function __promisify__(path: PathLike): Promise<Stats>;
564
557
  }
565
558
 
566
559
  /**
567
560
  * Synchronous lstat(2) - Get file status. Does not dereference symbolic links.
568
561
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
569
562
  */
570
- function lstatSync(path: PathLike, options?: StatOptions & { bigint?: false }): Stats;
571
- function lstatSync(path: PathLike, options: StatOptions & { bigint: true }): BigIntStats;
572
- function lstatSync(path: PathLike, options?: StatOptions): Stats | BigIntStats;
563
+ export function lstatSync(path: PathLike): Stats;
573
564
 
574
565
  /**
575
566
  * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
576
567
  * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
577
568
  * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
578
569
  */
579
- function link(existingPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
570
+ export function link(existingPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
580
571
 
581
572
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
582
- namespace link {
573
+ export namespace link {
583
574
  /**
584
575
  * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
585
576
  * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -593,7 +584,7 @@ declare module "fs" {
593
584
  * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
594
585
  * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
595
586
  */
596
- function linkSync(existingPath: PathLike, newPath: PathLike): void;
587
+ export function linkSync(existingPath: PathLike, newPath: PathLike): void;
597
588
 
598
589
  /**
599
590
  * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
@@ -602,17 +593,17 @@ declare module "fs" {
602
593
  * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
603
594
  * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
604
595
  */
605
- function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: NoParamCallback): void;
596
+ export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: NoParamCallback): void;
606
597
 
607
598
  /**
608
599
  * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
609
600
  * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
610
601
  * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
611
602
  */
612
- function symlink(target: PathLike, path: PathLike, callback: NoParamCallback): void;
603
+ export function symlink(target: PathLike, path: PathLike, callback: NoParamCallback): void;
613
604
 
614
605
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
615
- namespace symlink {
606
+ export namespace symlink {
616
607
  /**
617
608
  * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
618
609
  * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
@@ -632,16 +623,16 @@ declare module "fs" {
632
623
  * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
633
624
  * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
634
625
  */
635
- function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
626
+ export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
636
627
 
637
628
  /**
638
629
  * Asynchronous readlink(2) - read value of a symbolic link.
639
630
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
640
631
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
641
632
  */
642
- function readlink(
633
+ export function readlink(
643
634
  path: PathLike,
644
- options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null,
635
+ options: BaseEncodingOptions | BufferEncoding | undefined | null,
645
636
  callback: (err: NodeJS.ErrnoException | null, linkString: string) => void
646
637
  ): void;
647
638
 
@@ -650,43 +641,43 @@ declare module "fs" {
650
641
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
651
642
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
652
643
  */
653
- function readlink(path: PathLike, options: { encoding: "buffer" } | "buffer", callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void;
644
+ export function readlink(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void;
654
645
 
655
646
  /**
656
647
  * Asynchronous readlink(2) - read value of a symbolic link.
657
648
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
658
649
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
659
650
  */
660
- function readlink(path: PathLike, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void): void;
651
+ export function readlink(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void): void;
661
652
 
662
653
  /**
663
654
  * Asynchronous readlink(2) - read value of a symbolic link.
664
655
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
665
656
  */
666
- function readlink(path: PathLike, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void;
657
+ export function readlink(path: PathLike, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void;
667
658
 
668
659
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
669
- namespace readlink {
660
+ export namespace readlink {
670
661
  /**
671
662
  * Asynchronous readlink(2) - read value of a symbolic link.
672
663
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
673
664
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
674
665
  */
675
- function __promisify__(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
666
+ function __promisify__(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>;
676
667
 
677
668
  /**
678
669
  * Asynchronous readlink(2) - read value of a symbolic link.
679
670
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
680
671
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
681
672
  */
682
- function __promisify__(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
673
+ function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
683
674
 
684
675
  /**
685
676
  * Asynchronous readlink(2) - read value of a symbolic link.
686
677
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
687
678
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
688
679
  */
689
- function __promisify__(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
680
+ function __promisify__(path: PathLike, options?: BaseEncodingOptions | string | null): Promise<string | Buffer>;
690
681
  }
691
682
 
692
683
  /**
@@ -694,30 +685,30 @@ declare module "fs" {
694
685
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
695
686
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
696
687
  */
697
- function readlinkSync(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
688
+ export function readlinkSync(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string;
698
689
 
699
690
  /**
700
691
  * Synchronous readlink(2) - read value of a symbolic link.
701
692
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
702
693
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
703
694
  */
704
- function readlinkSync(path: PathLike, options: { encoding: "buffer" } | "buffer"): Buffer;
695
+ export function readlinkSync(path: PathLike, options: BufferEncodingOption): Buffer;
705
696
 
706
697
  /**
707
698
  * Synchronous readlink(2) - read value of a symbolic link.
708
699
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
709
700
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
710
701
  */
711
- function readlinkSync(path: PathLike, options?: { encoding?: string | null } | string | null): string | Buffer;
702
+ export function readlinkSync(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer;
712
703
 
713
704
  /**
714
705
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
715
706
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
716
707
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
717
708
  */
718
- function realpath(
709
+ export function realpath(
719
710
  path: PathLike,
720
- options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null,
711
+ options: BaseEncodingOptions | BufferEncoding | undefined | null,
721
712
  callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void
722
713
  ): void;
723
714
 
@@ -726,51 +717,51 @@ declare module "fs" {
726
717
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
727
718
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
728
719
  */
729
- function realpath(path: PathLike, options: { encoding: "buffer" } | "buffer", callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
720
+ export function realpath(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
730
721
 
731
722
  /**
732
723
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
733
724
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
734
725
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
735
726
  */
736
- function realpath(path: PathLike, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
727
+ export function realpath(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
737
728
 
738
729
  /**
739
730
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
740
731
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
741
732
  */
742
- function realpath(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
733
+ export function realpath(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
743
734
 
744
735
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
745
- namespace realpath {
736
+ export namespace realpath {
746
737
  /**
747
738
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
748
739
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
749
740
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
750
741
  */
751
- function __promisify__(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
742
+ function __promisify__(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>;
752
743
 
753
744
  /**
754
745
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
755
746
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
756
747
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
757
748
  */
758
- function __promisify__(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
749
+ function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
759
750
 
760
751
  /**
761
752
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
762
753
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
763
754
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
764
755
  */
765
- function __promisify__(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
756
+ function __promisify__(path: PathLike, options?: BaseEncodingOptions | string | null): Promise<string | Buffer>;
766
757
 
767
758
  function native(
768
759
  path: PathLike,
769
- options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null,
760
+ options: BaseEncodingOptions | BufferEncoding | undefined | null,
770
761
  callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void
771
762
  ): void;
772
- function native(path: PathLike, options: { encoding: "buffer" } | "buffer", callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
773
- function native(path: PathLike, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
763
+ function native(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
764
+ function native(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
774
765
  function native(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
775
766
  }
776
767
 
@@ -779,36 +770,36 @@ declare module "fs" {
779
770
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
780
771
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
781
772
  */
782
- function realpathSync(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
773
+ export function realpathSync(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string;
783
774
 
784
775
  /**
785
776
  * Synchronous realpath(3) - return the canonicalized absolute pathname.
786
777
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
787
778
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
788
779
  */
789
- function realpathSync(path: PathLike, options: { encoding: "buffer" } | "buffer"): Buffer;
780
+ export function realpathSync(path: PathLike, options: BufferEncodingOption): Buffer;
790
781
 
791
782
  /**
792
783
  * Synchronous realpath(3) - return the canonicalized absolute pathname.
793
784
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
794
785
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
795
786
  */
796
- function realpathSync(path: PathLike, options?: { encoding?: string | null } | string | null): string | Buffer;
787
+ export function realpathSync(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer;
797
788
 
798
- namespace realpathSync {
799
- function native(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
800
- function native(path: PathLike, options: { encoding: "buffer" } | "buffer"): Buffer;
801
- function native(path: PathLike, options?: { encoding?: string | null } | string | null): string | Buffer;
789
+ export namespace realpathSync {
790
+ function native(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string;
791
+ function native(path: PathLike, options: BufferEncodingOption): Buffer;
792
+ function native(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer;
802
793
  }
803
794
 
804
795
  /**
805
796
  * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
806
797
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
807
798
  */
808
- function unlink(path: PathLike, callback: NoParamCallback): void;
799
+ export function unlink(path: PathLike, callback: NoParamCallback): void;
809
800
 
810
801
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
811
- namespace unlink {
802
+ export namespace unlink {
812
803
  /**
813
804
  * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
814
805
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -820,18 +811,9 @@ declare module "fs" {
820
811
  * Synchronous unlink(2) - delete a name and possibly the file it refers to.
821
812
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
822
813
  */
823
- function unlinkSync(path: PathLike): void;
814
+ export function unlinkSync(path: PathLike): void;
824
815
 
825
- interface RmDirOptions {
826
- /**
827
- * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
828
- * `EPERM` error is encountered, Node.js will retry the operation with a linear
829
- * backoff wait of `retryDelay` ms longer on each try. This option represents the
830
- * number of retries. This option is ignored if the `recursive` option is not
831
- * `true`.
832
- * @default 0
833
- */
834
- maxRetries?: number;
816
+ export interface RmDirOptions {
835
817
  /**
836
818
  * If `true`, perform a recursive directory removal. In
837
819
  * recursive mode, errors are not reported if `path` does not exist, and
@@ -840,37 +822,49 @@ declare module "fs" {
840
822
  * @default false
841
823
  */
842
824
  recursive?: boolean;
825
+ }
826
+
827
+ export interface RmDirAsyncOptions extends RmDirOptions {
843
828
  /**
844
829
  * The amount of time in milliseconds to wait between retries.
845
830
  * This option is ignored if the `recursive` option is not `true`.
846
831
  * @default 100
847
832
  */
848
833
  retryDelay?: number;
834
+ /**
835
+ * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
836
+ * `EPERM` error is encountered, Node.js will retry the operation with a linear
837
+ * backoff wait of `retryDelay` ms longer on each try. This option represents the
838
+ * number of retries. This option is ignored if the `recursive` option is not
839
+ * `true`.
840
+ * @default 0
841
+ */
842
+ maxRetries?: number;
849
843
  }
850
844
 
851
845
  /**
852
846
  * Asynchronous rmdir(2) - delete a directory.
853
847
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
854
848
  */
855
- function rmdir(path: PathLike, callback: NoParamCallback): void;
856
- function rmdir(path: PathLike, options: RmDirOptions, callback: NoParamCallback): void;
849
+ export function rmdir(path: PathLike, callback: NoParamCallback): void;
850
+ export function rmdir(path: PathLike, options: RmDirAsyncOptions, callback: NoParamCallback): void;
857
851
 
858
852
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
859
- namespace rmdir {
853
+ export namespace rmdir {
860
854
  /**
861
855
  * Asynchronous rmdir(2) - delete a directory.
862
856
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
863
857
  */
864
- function __promisify__(path: PathLike, options?: RmDirOptions): Promise<void>;
858
+ function __promisify__(path: PathLike, options?: RmDirAsyncOptions): Promise<void>;
865
859
  }
866
860
 
867
861
  /**
868
862
  * Synchronous rmdir(2) - delete a directory.
869
863
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
870
864
  */
871
- function rmdirSync(path: PathLike, options?: RmDirOptions): void;
865
+ export function rmdirSync(path: PathLike, options?: RmDirOptions): void;
872
866
 
873
- interface MakeDirectoryOptions {
867
+ export interface MakeDirectoryOptions {
874
868
  /**
875
869
  * Indicates whether parent folders should be created.
876
870
  * If a folder was created, the path to the first created folder will be returned.
@@ -881,7 +875,7 @@ declare module "fs" {
881
875
  * A file mode. If a string is passed, it is parsed as an octal integer. If not specified
882
876
  * @default 0o777
883
877
  */
884
- mode?: number | string;
878
+ mode?: Mode;
885
879
  }
886
880
 
887
881
  /**
@@ -890,7 +884,7 @@ declare module "fs" {
890
884
  * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
891
885
  * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
892
886
  */
893
- function mkdir(path: PathLike, options: MakeDirectoryOptions & { recursive: true }, callback: (err: NodeJS.ErrnoException | null, path?: string) => void): void;
887
+ export function mkdir(path: PathLike, options: MakeDirectoryOptions & { recursive: true }, callback: (err: NodeJS.ErrnoException | null, path: string) => void): void;
894
888
 
895
889
  /**
896
890
  * Asynchronous mkdir(2) - create a directory.
@@ -898,7 +892,7 @@ declare module "fs" {
898
892
  * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
899
893
  * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
900
894
  */
901
- function mkdir(path: PathLike, options: number | string | (MakeDirectoryOptions & { recursive?: false; }) | null | undefined, callback: NoParamCallback): void;
895
+ export function mkdir(path: PathLike, options: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null | undefined, callback: NoParamCallback): void;
902
896
 
903
897
  /**
904
898
  * Asynchronous mkdir(2) - create a directory.
@@ -906,23 +900,23 @@ declare module "fs" {
906
900
  * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
907
901
  * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
908
902
  */
909
- function mkdir(path: PathLike, options: number | string | MakeDirectoryOptions | null | undefined, callback: (err: NodeJS.ErrnoException | null, path?: string) => void): void;
903
+ export function mkdir(path: PathLike, options: Mode | MakeDirectoryOptions | null | undefined, callback: (err: NodeJS.ErrnoException | null, path: string | undefined) => void): void;
910
904
 
911
905
  /**
912
906
  * Asynchronous mkdir(2) - create a directory with a mode of `0o777`.
913
907
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
914
908
  */
915
- function mkdir(path: PathLike, callback: NoParamCallback): void;
909
+ export function mkdir(path: PathLike, callback: NoParamCallback): void;
916
910
 
917
911
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
918
- namespace mkdir {
912
+ export namespace mkdir {
919
913
  /**
920
914
  * Asynchronous mkdir(2) - create a directory.
921
915
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
922
916
  * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
923
917
  * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
924
918
  */
925
- function __promisify__(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): Promise<string | undefined>;
919
+ function __promisify__(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): Promise<string>;
926
920
 
927
921
  /**
928
922
  * Asynchronous mkdir(2) - create a directory.
@@ -930,7 +924,7 @@ declare module "fs" {
930
924
  * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
931
925
  * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
932
926
  */
933
- function __promisify__(path: PathLike, options?: number | string | (MakeDirectoryOptions & { recursive?: false; }) | null): Promise<void>;
927
+ function __promisify__(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null): Promise<void>;
934
928
 
935
929
  /**
936
930
  * Asynchronous mkdir(2) - create a directory.
@@ -938,7 +932,7 @@ declare module "fs" {
938
932
  * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
939
933
  * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
940
934
  */
941
- function __promisify__(path: PathLike, options?: number | string | MakeDirectoryOptions | null): Promise<string | undefined>;
935
+ function __promisify__(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise<string | undefined>;
942
936
  }
943
937
 
944
938
  /**
@@ -947,7 +941,7 @@ declare module "fs" {
947
941
  * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
948
942
  * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
949
943
  */
950
- function mkdirSync(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): string | undefined;
944
+ export function mkdirSync(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): string;
951
945
 
952
946
  /**
953
947
  * Synchronous mkdir(2) - create a directory.
@@ -955,7 +949,7 @@ declare module "fs" {
955
949
  * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
956
950
  * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
957
951
  */
958
- function mkdirSync(path: PathLike, options?: number | string | (MakeDirectoryOptions & { recursive?: false; }) | null): void;
952
+ export function mkdirSync(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null): void;
959
953
 
960
954
  /**
961
955
  * Synchronous mkdir(2) - create a directory.
@@ -963,57 +957,57 @@ declare module "fs" {
963
957
  * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
964
958
  * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
965
959
  */
966
- function mkdirSync(path: PathLike, options?: number | string | MakeDirectoryOptions | null): string | undefined;
960
+ export function mkdirSync(path: PathLike, options?: Mode | MakeDirectoryOptions | null): string | undefined;
967
961
 
968
962
  /**
969
963
  * Asynchronously creates a unique temporary directory.
970
964
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
971
965
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
972
966
  */
973
- function mkdtemp(prefix: string, options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
967
+ export function mkdtemp(prefix: string, options: BaseEncodingOptions | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
974
968
 
975
969
  /**
976
970
  * Asynchronously creates a unique temporary directory.
977
971
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
978
972
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
979
973
  */
980
- function mkdtemp(prefix: string, options: "buffer" | { encoding: "buffer" }, callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void): void;
974
+ export function mkdtemp(prefix: string, options: "buffer" | { encoding: "buffer" }, callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void): void;
981
975
 
982
976
  /**
983
977
  * Asynchronously creates a unique temporary directory.
984
978
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
985
979
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
986
980
  */
987
- function mkdtemp(prefix: string, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void): void;
981
+ export function mkdtemp(prefix: string, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void): void;
988
982
 
989
983
  /**
990
984
  * Asynchronously creates a unique temporary directory.
991
985
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
992
986
  */
993
- function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
987
+ export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
994
988
 
995
989
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
996
- namespace mkdtemp {
990
+ export namespace mkdtemp {
997
991
  /**
998
992
  * Asynchronously creates a unique temporary directory.
999
993
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1000
994
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1001
995
  */
1002
- function __promisify__(prefix: string, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
996
+ function __promisify__(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>;
1003
997
 
1004
998
  /**
1005
999
  * Asynchronously creates a unique temporary directory.
1006
1000
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1007
1001
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1008
1002
  */
1009
- function __promisify__(prefix: string, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
1003
+ function __promisify__(prefix: string, options: BufferEncodingOption): Promise<Buffer>;
1010
1004
 
1011
1005
  /**
1012
1006
  * Asynchronously creates a unique temporary directory.
1013
1007
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1014
1008
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1015
1009
  */
1016
- function __promisify__(prefix: string, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
1010
+ function __promisify__(prefix: string, options?: BaseEncodingOptions | string | null): Promise<string | Buffer>;
1017
1011
  }
1018
1012
 
1019
1013
  /**
@@ -1021,28 +1015,28 @@ declare module "fs" {
1021
1015
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1022
1016
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1023
1017
  */
1024
- function mkdtempSync(prefix: string, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
1018
+ export function mkdtempSync(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): string;
1025
1019
 
1026
1020
  /**
1027
1021
  * Synchronously creates a unique temporary directory.
1028
1022
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1029
1023
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1030
1024
  */
1031
- function mkdtempSync(prefix: string, options: { encoding: "buffer" } | "buffer"): Buffer;
1025
+ export function mkdtempSync(prefix: string, options: BufferEncodingOption): Buffer;
1032
1026
 
1033
1027
  /**
1034
1028
  * Synchronously creates a unique temporary directory.
1035
1029
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1036
1030
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1037
1031
  */
1038
- function mkdtempSync(prefix: string, options?: { encoding?: string | null } | string | null): string | Buffer;
1032
+ export function mkdtempSync(prefix: string, options?: BaseEncodingOptions | string | null): string | Buffer;
1039
1033
 
1040
1034
  /**
1041
1035
  * Asynchronous readdir(3) - read a directory.
1042
1036
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1043
1037
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1044
1038
  */
1045
- function readdir(
1039
+ export function readdir(
1046
1040
  path: PathLike,
1047
1041
  options: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | undefined | null,
1048
1042
  callback: (err: NodeJS.ErrnoException | null, files: string[]) => void,
@@ -1053,16 +1047,16 @@ declare module "fs" {
1053
1047
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1054
1048
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1055
1049
  */
1056
- function readdir(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer", callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void): void;
1050
+ export function readdir(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer", callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void): void;
1057
1051
 
1058
1052
  /**
1059
1053
  * Asynchronous readdir(3) - read a directory.
1060
1054
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1061
1055
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1062
1056
  */
1063
- function readdir(
1057
+ export function readdir(
1064
1058
  path: PathLike,
1065
- options: { encoding?: string | null; withFileTypes?: false } | string | undefined | null,
1059
+ options: BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | undefined | null,
1066
1060
  callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void,
1067
1061
  ): void;
1068
1062
 
@@ -1070,17 +1064,17 @@ declare module "fs" {
1070
1064
  * Asynchronous readdir(3) - read a directory.
1071
1065
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1072
1066
  */
1073
- function readdir(path: PathLike, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
1067
+ export function readdir(path: PathLike, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
1074
1068
 
1075
1069
  /**
1076
1070
  * Asynchronous readdir(3) - read a directory.
1077
1071
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1078
1072
  * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
1079
1073
  */
1080
- function readdir(path: PathLike, options: { encoding?: string | null; withFileTypes: true }, callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void): void;
1074
+ export function readdir(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }, callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void): void;
1081
1075
 
1082
1076
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1083
- namespace readdir {
1077
+ export namespace readdir {
1084
1078
  /**
1085
1079
  * Asynchronous readdir(3) - read a directory.
1086
1080
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -1100,14 +1094,14 @@ declare module "fs" {
1100
1094
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1101
1095
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1102
1096
  */
1103
- function __promisify__(path: PathLike, options?: { encoding?: string | null; withFileTypes?: false } | string | null): Promise<string[] | Buffer[]>;
1097
+ function __promisify__(path: PathLike, options?: BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | null): Promise<string[] | Buffer[]>;
1104
1098
 
1105
1099
  /**
1106
1100
  * Asynchronous readdir(3) - read a directory.
1107
1101
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1108
1102
  * @param options If called with `withFileTypes: true` the result data will be an array of Dirent
1109
1103
  */
1110
- function __promisify__(path: PathLike, options: { encoding?: string | null; withFileTypes: true }): Promise<Dirent[]>;
1104
+ function __promisify__(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Promise<Dirent[]>;
1111
1105
  }
1112
1106
 
1113
1107
  /**
@@ -1115,37 +1109,37 @@ declare module "fs" {
1115
1109
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1116
1110
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1117
1111
  */
1118
- function readdirSync(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): string[];
1112
+ export function readdirSync(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): string[];
1119
1113
 
1120
1114
  /**
1121
1115
  * Synchronous readdir(3) - read a directory.
1122
1116
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1123
1117
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1124
1118
  */
1125
- function readdirSync(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer"): Buffer[];
1119
+ export function readdirSync(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer"): Buffer[];
1126
1120
 
1127
1121
  /**
1128
1122
  * Synchronous readdir(3) - read a directory.
1129
1123
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1130
1124
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1131
1125
  */
1132
- function readdirSync(path: PathLike, options?: { encoding?: string | null; withFileTypes?: false } | string | null): string[] | Buffer[];
1126
+ export function readdirSync(path: PathLike, options?: BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | null): string[] | Buffer[];
1133
1127
 
1134
1128
  /**
1135
1129
  * Synchronous readdir(3) - read a directory.
1136
1130
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1137
1131
  * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
1138
1132
  */
1139
- function readdirSync(path: PathLike, options: { encoding?: string | null; withFileTypes: true }): Dirent[];
1133
+ export function readdirSync(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Dirent[];
1140
1134
 
1141
1135
  /**
1142
1136
  * Asynchronous close(2) - close a file descriptor.
1143
1137
  * @param fd A file descriptor.
1144
1138
  */
1145
- function close(fd: number, callback: NoParamCallback): void;
1139
+ export function close(fd: number, callback: NoParamCallback): void;
1146
1140
 
1147
1141
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1148
- namespace close {
1142
+ export namespace close {
1149
1143
  /**
1150
1144
  * Asynchronous close(2) - close a file descriptor.
1151
1145
  * @param fd A file descriptor.
@@ -1157,29 +1151,29 @@ declare module "fs" {
1157
1151
  * Synchronous close(2) - close a file descriptor.
1158
1152
  * @param fd A file descriptor.
1159
1153
  */
1160
- function closeSync(fd: number): void;
1154
+ export function closeSync(fd: number): void;
1161
1155
 
1162
1156
  /**
1163
1157
  * Asynchronous open(2) - open and possibly create a file.
1164
1158
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1165
1159
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
1166
1160
  */
1167
- function open(path: PathLike, flags: string | number, mode: string | number | undefined | null, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
1161
+ export function open(path: PathLike, flags: OpenMode, mode: Mode | undefined | null, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
1168
1162
 
1169
1163
  /**
1170
1164
  * Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
1171
1165
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1172
1166
  */
1173
- function open(path: PathLike, flags: string | number, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
1167
+ export function open(path: PathLike, flags: OpenMode, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
1174
1168
 
1175
1169
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1176
- namespace open {
1170
+ export namespace open {
1177
1171
  /**
1178
1172
  * Asynchronous open(2) - open and possibly create a file.
1179
1173
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1180
1174
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
1181
1175
  */
1182
- function __promisify__(path: PathLike, flags: string | number, mode?: string | number | null): Promise<number>;
1176
+ function __promisify__(path: PathLike, flags: OpenMode, mode?: Mode | null): Promise<number>;
1183
1177
  }
1184
1178
 
1185
1179
  /**
@@ -1187,7 +1181,7 @@ declare module "fs" {
1187
1181
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1188
1182
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
1189
1183
  */
1190
- function openSync(path: PathLike, flags: string | number, mode?: string | number | null): number;
1184
+ export function openSync(path: PathLike, flags: OpenMode, mode?: Mode | null): number;
1191
1185
 
1192
1186
  /**
1193
1187
  * Asynchronously change file timestamps of the file referenced by the supplied path.
@@ -1195,10 +1189,10 @@ declare module "fs" {
1195
1189
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1196
1190
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1197
1191
  */
1198
- function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
1192
+ export function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
1199
1193
 
1200
1194
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1201
- namespace utimes {
1195
+ export namespace utimes {
1202
1196
  /**
1203
1197
  * Asynchronously change file timestamps of the file referenced by the supplied path.
1204
1198
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -1214,7 +1208,7 @@ declare module "fs" {
1214
1208
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1215
1209
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1216
1210
  */
1217
- function utimesSync(path: PathLike, atime: string | number | Date, mtime: string | number | Date): void;
1211
+ export function utimesSync(path: PathLike, atime: string | number | Date, mtime: string | number | Date): void;
1218
1212
 
1219
1213
  /**
1220
1214
  * Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
@@ -1222,10 +1216,10 @@ declare module "fs" {
1222
1216
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1223
1217
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1224
1218
  */
1225
- function futimes(fd: number, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
1219
+ export function futimes(fd: number, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
1226
1220
 
1227
1221
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1228
- namespace futimes {
1222
+ export namespace futimes {
1229
1223
  /**
1230
1224
  * Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
1231
1225
  * @param fd A file descriptor.
@@ -1241,16 +1235,16 @@ declare module "fs" {
1241
1235
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1242
1236
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1243
1237
  */
1244
- function futimesSync(fd: number, atime: string | number | Date, mtime: string | number | Date): void;
1238
+ export function futimesSync(fd: number, atime: string | number | Date, mtime: string | number | Date): void;
1245
1239
 
1246
1240
  /**
1247
1241
  * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
1248
1242
  * @param fd A file descriptor.
1249
1243
  */
1250
- function fsync(fd: number, callback: NoParamCallback): void;
1244
+ export function fsync(fd: number, callback: NoParamCallback): void;
1251
1245
 
1252
1246
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1253
- namespace fsync {
1247
+ export namespace fsync {
1254
1248
  /**
1255
1249
  * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
1256
1250
  * @param fd A file descriptor.
@@ -1262,7 +1256,7 @@ declare module "fs" {
1262
1256
  * Synchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
1263
1257
  * @param fd A file descriptor.
1264
1258
  */
1265
- function fsyncSync(fd: number): void;
1259
+ export function fsyncSync(fd: number): void;
1266
1260
 
1267
1261
  /**
1268
1262
  * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
@@ -1271,7 +1265,7 @@ declare module "fs" {
1271
1265
  * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
1272
1266
  * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
1273
1267
  */
1274
- function write<TBuffer extends NodeJS.ArrayBufferView>(
1268
+ export function write<TBuffer extends NodeJS.ArrayBufferView>(
1275
1269
  fd: number,
1276
1270
  buffer: TBuffer,
1277
1271
  offset: number | undefined | null,
@@ -1286,7 +1280,7 @@ declare module "fs" {
1286
1280
  * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
1287
1281
  * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
1288
1282
  */
1289
- function write<TBuffer extends NodeJS.ArrayBufferView>(
1283
+ export function write<TBuffer extends NodeJS.ArrayBufferView>(
1290
1284
  fd: number,
1291
1285
  buffer: TBuffer,
1292
1286
  offset: number | undefined | null,
@@ -1299,7 +1293,7 @@ declare module "fs" {
1299
1293
  * @param fd A file descriptor.
1300
1294
  * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
1301
1295
  */
1302
- function write<TBuffer extends NodeJS.ArrayBufferView>(
1296
+ export function write<TBuffer extends NodeJS.ArrayBufferView>(
1303
1297
  fd: number,
1304
1298
  buffer: TBuffer,
1305
1299
  offset: number | undefined | null,
@@ -1310,40 +1304,40 @@ declare module "fs" {
1310
1304
  * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
1311
1305
  * @param fd A file descriptor.
1312
1306
  */
1313
- function write<TBuffer extends NodeJS.ArrayBufferView>(fd: number, buffer: TBuffer, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void): void;
1307
+ export function write<TBuffer extends NodeJS.ArrayBufferView>(fd: number, buffer: TBuffer, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void): void;
1314
1308
 
1315
1309
  /**
1316
1310
  * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
1317
1311
  * @param fd A file descriptor.
1318
- * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
1312
+ * @param string A string to write.
1319
1313
  * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
1320
1314
  * @param encoding The expected string encoding.
1321
1315
  */
1322
- function write(
1316
+ export function write(
1323
1317
  fd: number,
1324
- string: any,
1318
+ string: string,
1325
1319
  position: number | undefined | null,
1326
- encoding: string | undefined | null,
1320
+ encoding: BufferEncoding | undefined | null,
1327
1321
  callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void,
1328
1322
  ): void;
1329
1323
 
1330
1324
  /**
1331
1325
  * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
1332
1326
  * @param fd A file descriptor.
1333
- * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
1327
+ * @param string A string to write.
1334
1328
  * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
1335
1329
  */
1336
- function write(fd: number, string: any, position: number | undefined | null, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
1330
+ export function write(fd: number, string: string, position: number | undefined | null, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
1337
1331
 
1338
1332
  /**
1339
1333
  * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
1340
1334
  * @param fd A file descriptor.
1341
- * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
1335
+ * @param string A string to write.
1342
1336
  */
1343
- function write(fd: number, string: any, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
1337
+ export function write(fd: number, string: string, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
1344
1338
 
1345
1339
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1346
- namespace write {
1340
+ export namespace write {
1347
1341
  /**
1348
1342
  * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
1349
1343
  * @param fd A file descriptor.
@@ -1362,11 +1356,11 @@ declare module "fs" {
1362
1356
  /**
1363
1357
  * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
1364
1358
  * @param fd A file descriptor.
1365
- * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
1359
+ * @param string A string to write.
1366
1360
  * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
1367
1361
  * @param encoding The expected string encoding.
1368
1362
  */
1369
- function __promisify__(fd: number, string: any, position?: number | null, encoding?: string | null): Promise<{ bytesWritten: number, buffer: string }>;
1363
+ function __promisify__(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): Promise<{ bytesWritten: number, buffer: string }>;
1370
1364
  }
1371
1365
 
1372
1366
  /**
@@ -1376,16 +1370,16 @@ declare module "fs" {
1376
1370
  * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
1377
1371
  * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
1378
1372
  */
1379
- function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
1373
+ export function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
1380
1374
 
1381
1375
  /**
1382
1376
  * Synchronously writes `string` to the file referenced by the supplied file descriptor, returning the number of bytes written.
1383
1377
  * @param fd A file descriptor.
1384
- * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
1378
+ * @param string A string to write.
1385
1379
  * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
1386
1380
  * @param encoding The expected string encoding.
1387
1381
  */
1388
- function writeSync(fd: number, string: any, position?: number | null, encoding?: string | null): number;
1382
+ export function writeSync(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): number;
1389
1383
 
1390
1384
  /**
1391
1385
  * Asynchronously reads data from the file referenced by the supplied file descriptor.
@@ -1395,7 +1389,7 @@ declare module "fs" {
1395
1389
  * @param length The number of bytes to read.
1396
1390
  * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
1397
1391
  */
1398
- function read<TBuffer extends NodeJS.ArrayBufferView>(
1392
+ export function read<TBuffer extends NodeJS.ArrayBufferView>(
1399
1393
  fd: number,
1400
1394
  buffer: TBuffer,
1401
1395
  offset: number,
@@ -1405,7 +1399,7 @@ declare module "fs" {
1405
1399
  ): void;
1406
1400
 
1407
1401
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1408
- namespace read {
1402
+ export namespace read {
1409
1403
  /**
1410
1404
  * @param fd A file descriptor.
1411
1405
  * @param buffer The buffer that the data will be written to.
@@ -1422,7 +1416,7 @@ declare module "fs" {
1422
1416
  ): Promise<{ bytesRead: number, buffer: TBuffer }>;
1423
1417
  }
1424
1418
 
1425
- interface ReadSyncOptions {
1419
+ export interface ReadSyncOptions {
1426
1420
  /**
1427
1421
  * @default 0
1428
1422
  */
@@ -1445,13 +1439,13 @@ declare module "fs" {
1445
1439
  * @param length The number of bytes to read.
1446
1440
  * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
1447
1441
  */
1448
- function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: number | null): number;
1442
+ export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: number | null): number;
1449
1443
 
1450
1444
  /**
1451
1445
  * Similar to the above `fs.readSync` function, this version takes an optional `options` object.
1452
1446
  * If no `options` object is specified, it will default with the above values.
1453
1447
  */
1454
- function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadSyncOptions): number;
1448
+ export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadSyncOptions): number;
1455
1449
 
1456
1450
  /**
1457
1451
  * Asynchronously reads the entire contents of a file.
@@ -1460,7 +1454,7 @@ declare module "fs" {
1460
1454
  * @param options An object that may contain an optional flag.
1461
1455
  * If a flag is not provided, it defaults to `'r'`.
1462
1456
  */
1463
- function readFile(path: PathLike | number, options: { encoding?: null; flag?: string; } | undefined | null, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
1457
+ export function readFile(path: PathLike | number, options: { encoding?: null; flag?: string; } | undefined | null, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
1464
1458
 
1465
1459
  /**
1466
1460
  * Asynchronously reads the entire contents of a file.
@@ -1470,7 +1464,7 @@ declare module "fs" {
1470
1464
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1471
1465
  * If a flag is not provided, it defaults to `'r'`.
1472
1466
  */
1473
- function readFile(path: PathLike | number, options: { encoding: string; flag?: string; } | string, callback: (err: NodeJS.ErrnoException | null, data: string) => void): void;
1467
+ export function readFile(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string; } | string, callback: (err: NodeJS.ErrnoException | null, data: string) => void): void;
1474
1468
 
1475
1469
  /**
1476
1470
  * Asynchronously reads the entire contents of a file.
@@ -1480,9 +1474,9 @@ declare module "fs" {
1480
1474
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1481
1475
  * If a flag is not provided, it defaults to `'r'`.
1482
1476
  */
1483
- function readFile(
1477
+ export function readFile(
1484
1478
  path: PathLike | number,
1485
- options: { encoding?: string | null; flag?: string; } | string | undefined | null,
1479
+ options: BaseEncodingOptions & { flag?: string; } | string | undefined | null,
1486
1480
  callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void,
1487
1481
  ): void;
1488
1482
 
@@ -1491,10 +1485,10 @@ declare module "fs" {
1491
1485
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1492
1486
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1493
1487
  */
1494
- function readFile(path: PathLike | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
1488
+ export function readFile(path: PathLike | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
1495
1489
 
1496
1490
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1497
- namespace readFile {
1491
+ export namespace readFile {
1498
1492
  /**
1499
1493
  * Asynchronously reads the entire contents of a file.
1500
1494
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -1512,7 +1506,7 @@ declare module "fs" {
1512
1506
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1513
1507
  * If a flag is not provided, it defaults to `'r'`.
1514
1508
  */
1515
- function __promisify__(path: PathLike | number, options: { encoding: string; flag?: string; } | string): Promise<string>;
1509
+ function __promisify__(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string; } | string): Promise<string>;
1516
1510
 
1517
1511
  /**
1518
1512
  * Asynchronously reads the entire contents of a file.
@@ -1522,7 +1516,7 @@ declare module "fs" {
1522
1516
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1523
1517
  * If a flag is not provided, it defaults to `'r'`.
1524
1518
  */
1525
- function __promisify__(path: PathLike | number, options?: { encoding?: string | null; flag?: string; } | string | null): Promise<string | Buffer>;
1519
+ function __promisify__(path: PathLike | number, options?: BaseEncodingOptions & { flag?: string; } | string | null): Promise<string | Buffer>;
1526
1520
  }
1527
1521
 
1528
1522
  /**
@@ -1532,7 +1526,7 @@ declare module "fs" {
1532
1526
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1533
1527
  * @param options An object that may contain an optional flag. If a flag is not provided, it defaults to `'r'`.
1534
1528
  */
1535
- function readFileSync(path: PathLike | number, options?: { encoding?: null; flag?: string; } | null): Buffer;
1529
+ export function readFileSync(path: PathLike | number, options?: { encoding?: null; flag?: string; } | null): Buffer;
1536
1530
 
1537
1531
  /**
1538
1532
  * Synchronously reads the entire contents of a file.
@@ -1542,7 +1536,7 @@ declare module "fs" {
1542
1536
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1543
1537
  * If a flag is not provided, it defaults to `'r'`.
1544
1538
  */
1545
- function readFileSync(path: PathLike | number, options: { encoding: string; flag?: string; } | string): string;
1539
+ export function readFileSync(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string; } | BufferEncoding): string;
1546
1540
 
1547
1541
  /**
1548
1542
  * Synchronously reads the entire contents of a file.
@@ -1552,9 +1546,9 @@ declare module "fs" {
1552
1546
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1553
1547
  * If a flag is not provided, it defaults to `'r'`.
1554
1548
  */
1555
- function readFileSync(path: PathLike | number, options?: { encoding?: string | null; flag?: string; } | string | null): string | Buffer;
1549
+ export function readFileSync(path: PathLike | number, options?: BaseEncodingOptions & { flag?: string; } | BufferEncoding | null): string | Buffer;
1556
1550
 
1557
- type WriteFileOptions = { encoding?: string | null; mode?: number | string; flag?: string; } | string | null;
1551
+ export type WriteFileOptions = BaseEncodingOptions & { mode?: Mode; flag?: string; } | string | null;
1558
1552
 
1559
1553
  /**
1560
1554
  * Asynchronously writes data to a file, replacing the file if it already exists.
@@ -1568,7 +1562,7 @@ declare module "fs" {
1568
1562
  * If `mode` is a string, it is parsed as an octal integer.
1569
1563
  * If `flag` is not supplied, the default of `'w'` is used.
1570
1564
  */
1571
- function writeFile(path: PathLike | number, data: any, options: WriteFileOptions, callback: NoParamCallback): void;
1565
+ export function writeFile(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: NoParamCallback): void;
1572
1566
 
1573
1567
  /**
1574
1568
  * Asynchronously writes data to a file, replacing the file if it already exists.
@@ -1577,10 +1571,10 @@ declare module "fs" {
1577
1571
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1578
1572
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1579
1573
  */
1580
- function writeFile(path: PathLike | number, data: any, callback: NoParamCallback): void;
1574
+ export function writeFile(path: PathLike | number, data: string | NodeJS.ArrayBufferView, callback: NoParamCallback): void;
1581
1575
 
1582
1576
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1583
- namespace writeFile {
1577
+ export namespace writeFile {
1584
1578
  /**
1585
1579
  * Asynchronously writes data to a file, replacing the file if it already exists.
1586
1580
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -1593,7 +1587,7 @@ declare module "fs" {
1593
1587
  * If `mode` is a string, it is parsed as an octal integer.
1594
1588
  * If `flag` is not supplied, the default of `'w'` is used.
1595
1589
  */
1596
- function __promisify__(path: PathLike | number, data: any, options?: WriteFileOptions): Promise<void>;
1590
+ function __promisify__(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): Promise<void>;
1597
1591
  }
1598
1592
 
1599
1593
  /**
@@ -1608,7 +1602,7 @@ declare module "fs" {
1608
1602
  * If `mode` is a string, it is parsed as an octal integer.
1609
1603
  * If `flag` is not supplied, the default of `'w'` is used.
1610
1604
  */
1611
- function writeFileSync(path: PathLike | number, data: any, options?: WriteFileOptions): void;
1605
+ export function writeFileSync(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void;
1612
1606
 
1613
1607
  /**
1614
1608
  * Asynchronously append data to a file, creating the file if it does not exist.
@@ -1622,7 +1616,7 @@ declare module "fs" {
1622
1616
  * If `mode` is a string, it is parsed as an octal integer.
1623
1617
  * If `flag` is not supplied, the default of `'a'` is used.
1624
1618
  */
1625
- function appendFile(file: PathLike | number, data: any, options: WriteFileOptions, callback: NoParamCallback): void;
1619
+ export function appendFile(file: PathLike | number, data: string | Uint8Array, options: WriteFileOptions, callback: NoParamCallback): void;
1626
1620
 
1627
1621
  /**
1628
1622
  * Asynchronously append data to a file, creating the file if it does not exist.
@@ -1631,10 +1625,10 @@ declare module "fs" {
1631
1625
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1632
1626
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1633
1627
  */
1634
- function appendFile(file: PathLike | number, data: any, callback: NoParamCallback): void;
1628
+ export function appendFile(file: PathLike | number, data: string | Uint8Array, callback: NoParamCallback): void;
1635
1629
 
1636
1630
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1637
- namespace appendFile {
1631
+ export namespace appendFile {
1638
1632
  /**
1639
1633
  * Asynchronously append data to a file, creating the file if it does not exist.
1640
1634
  * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -1647,7 +1641,7 @@ declare module "fs" {
1647
1641
  * If `mode` is a string, it is parsed as an octal integer.
1648
1642
  * If `flag` is not supplied, the default of `'a'` is used.
1649
1643
  */
1650
- function __promisify__(file: PathLike | number, data: any, options?: WriteFileOptions): Promise<void>;
1644
+ function __promisify__(file: PathLike | number, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>;
1651
1645
  }
1652
1646
 
1653
1647
  /**
@@ -1662,26 +1656,26 @@ declare module "fs" {
1662
1656
  * If `mode` is a string, it is parsed as an octal integer.
1663
1657
  * If `flag` is not supplied, the default of `'a'` is used.
1664
1658
  */
1665
- function appendFileSync(file: PathLike | number, data: any, options?: WriteFileOptions): void;
1659
+ export function appendFileSync(file: PathLike | number, data: string | Uint8Array, options?: WriteFileOptions): void;
1666
1660
 
1667
1661
  /**
1668
1662
  * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
1669
1663
  */
1670
- function watchFile(filename: PathLike, options: { persistent?: boolean; interval?: number; } | undefined, listener: (curr: Stats, prev: Stats) => void): void;
1664
+ export function watchFile(filename: PathLike, options: { persistent?: boolean; interval?: number; } | undefined, listener: (curr: Stats, prev: Stats) => void): void;
1671
1665
 
1672
1666
  /**
1673
1667
  * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
1674
1668
  * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1675
1669
  * URL support is _experimental_.
1676
1670
  */
1677
- function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): void;
1671
+ export function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): void;
1678
1672
 
1679
1673
  /**
1680
1674
  * Stop watching for changes on `filename`.
1681
1675
  * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1682
1676
  * URL support is _experimental_.
1683
1677
  */
1684
- function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
1678
+ export function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
1685
1679
 
1686
1680
  /**
1687
1681
  * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
@@ -1692,7 +1686,7 @@ declare module "fs" {
1692
1686
  * If `persistent` is not supplied, the default of `true` is used.
1693
1687
  * If `recursive` is not supplied, the default of `false` is used.
1694
1688
  */
1695
- function watch(
1689
+ export function watch(
1696
1690
  filename: PathLike,
1697
1691
  options: { encoding?: BufferEncoding | null, persistent?: boolean, recursive?: boolean } | BufferEncoding | undefined | null,
1698
1692
  listener?: (event: string, filename: string) => void,
@@ -1707,7 +1701,7 @@ declare module "fs" {
1707
1701
  * If `persistent` is not supplied, the default of `true` is used.
1708
1702
  * If `recursive` is not supplied, the default of `false` is used.
1709
1703
  */
1710
- function watch(filename: PathLike, options: { encoding: "buffer", persistent?: boolean, recursive?: boolean } | "buffer", listener?: (event: string, filename: Buffer) => void): FSWatcher;
1704
+ export function watch(filename: PathLike, options: { encoding: "buffer", persistent?: boolean, recursive?: boolean } | "buffer", listener?: (event: string, filename: Buffer) => void): FSWatcher;
1711
1705
 
1712
1706
  /**
1713
1707
  * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
@@ -1718,9 +1712,9 @@ declare module "fs" {
1718
1712
  * If `persistent` is not supplied, the default of `true` is used.
1719
1713
  * If `recursive` is not supplied, the default of `false` is used.
1720
1714
  */
1721
- function watch(
1715
+ export function watch(
1722
1716
  filename: PathLike,
1723
- options: { encoding?: string | null, persistent?: boolean, recursive?: boolean } | string | null,
1717
+ options: { encoding?: BufferEncoding | null, persistent?: boolean, recursive?: boolean } | string | null,
1724
1718
  listener?: (event: string, filename: string | Buffer) => void,
1725
1719
  ): FSWatcher;
1726
1720
 
@@ -1729,7 +1723,7 @@ declare module "fs" {
1729
1723
  * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1730
1724
  * URL support is _experimental_.
1731
1725
  */
1732
- function watch(filename: PathLike, listener?: (event: string, filename: string) => any): FSWatcher;
1726
+ export function watch(filename: PathLike, listener?: (event: string, filename: string) => any): FSWatcher;
1733
1727
 
1734
1728
  /**
1735
1729
  * Asynchronously tests whether or not the given path exists by checking with the file system.
@@ -1737,10 +1731,10 @@ declare module "fs" {
1737
1731
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1738
1732
  * URL support is _experimental_.
1739
1733
  */
1740
- function exists(path: PathLike, callback: (exists: boolean) => void): void;
1734
+ export function exists(path: PathLike, callback: (exists: boolean) => void): void;
1741
1735
 
1742
1736
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1743
- namespace exists {
1737
+ export namespace exists {
1744
1738
  /**
1745
1739
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1746
1740
  * URL support is _experimental_.
@@ -1753,9 +1747,9 @@ declare module "fs" {
1753
1747
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1754
1748
  * URL support is _experimental_.
1755
1749
  */
1756
- function existsSync(path: PathLike): boolean;
1750
+ export function existsSync(path: PathLike): boolean;
1757
1751
 
1758
- namespace constants {
1752
+ export namespace constants {
1759
1753
  // File Access Constants
1760
1754
 
1761
1755
  /** Constant for fs.access(). File is visible to the calling process. */
@@ -1923,17 +1917,17 @@ declare module "fs" {
1923
1917
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1924
1918
  * URL support is _experimental_.
1925
1919
  */
1926
- function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void;
1920
+ export function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void;
1927
1921
 
1928
1922
  /**
1929
1923
  * Asynchronously tests a user's permissions for the file specified by path.
1930
1924
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1931
1925
  * URL support is _experimental_.
1932
1926
  */
1933
- function access(path: PathLike, callback: NoParamCallback): void;
1927
+ export function access(path: PathLike, callback: NoParamCallback): void;
1934
1928
 
1935
1929
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1936
- namespace access {
1930
+ export namespace access {
1937
1931
  /**
1938
1932
  * Asynchronously tests a user's permissions for the file specified by path.
1939
1933
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
@@ -1947,16 +1941,16 @@ declare module "fs" {
1947
1941
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1948
1942
  * URL support is _experimental_.
1949
1943
  */
1950
- function accessSync(path: PathLike, mode?: number): void;
1944
+ export function accessSync(path: PathLike, mode?: number): void;
1951
1945
 
1952
1946
  /**
1953
1947
  * Returns a new `ReadStream` object.
1954
1948
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1955
1949
  * URL support is _experimental_.
1956
1950
  */
1957
- function createReadStream(path: PathLike, options?: string | {
1951
+ export function createReadStream(path: PathLike, options?: string | {
1958
1952
  flags?: string;
1959
- encoding?: string;
1953
+ encoding?: BufferEncoding;
1960
1954
  fd?: number;
1961
1955
  mode?: number;
1962
1956
  autoClose?: boolean;
@@ -1974,9 +1968,9 @@ declare module "fs" {
1974
1968
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1975
1969
  * URL support is _experimental_.
1976
1970
  */
1977
- function createWriteStream(path: PathLike, options?: string | {
1971
+ export function createWriteStream(path: PathLike, options?: string | {
1978
1972
  flags?: string;
1979
- encoding?: string;
1973
+ encoding?: BufferEncoding;
1980
1974
  fd?: number;
1981
1975
  mode?: number;
1982
1976
  autoClose?: boolean;
@@ -1989,10 +1983,10 @@ declare module "fs" {
1989
1983
  * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
1990
1984
  * @param fd A file descriptor.
1991
1985
  */
1992
- function fdatasync(fd: number, callback: NoParamCallback): void;
1986
+ export function fdatasync(fd: number, callback: NoParamCallback): void;
1993
1987
 
1994
1988
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1995
- namespace fdatasync {
1989
+ export namespace fdatasync {
1996
1990
  /**
1997
1991
  * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
1998
1992
  * @param fd A file descriptor.
@@ -2004,7 +1998,7 @@ declare module "fs" {
2004
1998
  * Synchronous fdatasync(2) - synchronize a file's in-core state with storage device.
2005
1999
  * @param fd A file descriptor.
2006
2000
  */
2007
- function fdatasyncSync(fd: number): void;
2001
+ export function fdatasyncSync(fd: number): void;
2008
2002
 
2009
2003
  /**
2010
2004
  * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
@@ -2015,7 +2009,7 @@ declare module "fs" {
2015
2009
  * @param src A path to the source file.
2016
2010
  * @param dest A path to the destination file.
2017
2011
  */
2018
- function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void;
2012
+ export function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void;
2019
2013
  /**
2020
2014
  * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
2021
2015
  * No arguments other than a possible exception are given to the callback function.
@@ -2026,10 +2020,10 @@ declare module "fs" {
2026
2020
  * @param dest A path to the destination file.
2027
2021
  * @param flags An integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
2028
2022
  */
2029
- function copyFile(src: PathLike, dest: PathLike, flags: number, callback: NoParamCallback): void;
2023
+ export function copyFile(src: PathLike, dest: PathLike, flags: number, callback: NoParamCallback): void;
2030
2024
 
2031
2025
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
2032
- namespace copyFile {
2026
+ export namespace copyFile {
2033
2027
  /**
2034
2028
  * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
2035
2029
  * No arguments other than a possible exception are given to the callback function.
@@ -2055,7 +2049,7 @@ declare module "fs" {
2055
2049
  * @param flags An optional integer that specifies the behavior of the copy operation.
2056
2050
  * The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
2057
2051
  */
2058
- function copyFileSync(src: PathLike, dest: PathLike, flags?: number): void;
2052
+ export function copyFileSync(src: PathLike, dest: PathLike, flags?: number): void;
2059
2053
 
2060
2054
  /**
2061
2055
  * Write an array of ArrayBufferViews to the file specified by fd using writev().
@@ -2064,59 +2058,59 @@ declare module "fs" {
2064
2058
  * On Linux, positional writes don't work when the file is opened in append mode.
2065
2059
  * The kernel ignores the position argument and always appends the data to the end of the file.
2066
2060
  */
2067
- function writev(
2061
+ export function writev(
2068
2062
  fd: number,
2069
- buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
2063
+ buffers: NodeJS.ArrayBufferView[],
2070
2064
  cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
2071
2065
  ): void;
2072
- function writev(
2066
+ export function writev(
2073
2067
  fd: number,
2074
- buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
2068
+ buffers: NodeJS.ArrayBufferView[],
2075
2069
  position: number,
2076
2070
  cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
2077
2071
  ): void;
2078
2072
 
2079
- interface WriteVResult {
2073
+ export interface WriteVResult {
2080
2074
  bytesWritten: number;
2081
2075
  buffers: NodeJS.ArrayBufferView[];
2082
2076
  }
2083
2077
 
2084
- namespace writev {
2085
- function __promisify__(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<WriteVResult>;
2078
+ export namespace writev {
2079
+ function __promisify__(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise<WriteVResult>;
2086
2080
  }
2087
2081
 
2088
2082
  /**
2089
2083
  * See `writev`.
2090
2084
  */
2091
- function writevSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
2085
+ export function writevSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): number;
2092
2086
 
2093
- function readv(
2087
+ export function readv(
2094
2088
  fd: number,
2095
- buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
2089
+ buffers: NodeJS.ArrayBufferView[],
2096
2090
  cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void
2097
2091
  ): void;
2098
- function readv(
2092
+ export function readv(
2099
2093
  fd: number,
2100
- buffers: ReadonlyArray<NodeJS.ArrayBufferView>,
2094
+ buffers: NodeJS.ArrayBufferView[],
2101
2095
  position: number,
2102
2096
  cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void
2103
2097
  ): void;
2104
2098
 
2105
- interface ReadVResult {
2099
+ export interface ReadVResult {
2106
2100
  bytesRead: number;
2107
2101
  buffers: NodeJS.ArrayBufferView[];
2108
2102
  }
2109
2103
 
2110
- namespace readv {
2111
- function __promisify__(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<ReadVResult>;
2104
+ export namespace readv {
2105
+ function __promisify__(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise<ReadVResult>;
2112
2106
  }
2113
2107
 
2114
2108
  /**
2115
2109
  * See `readv`.
2116
2110
  */
2117
- function readvSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
2111
+ export function readvSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): number;
2118
2112
 
2119
- interface OpenDirOptions {
2113
+ export interface OpenDirOptions {
2120
2114
  encoding?: BufferEncoding;
2121
2115
  /**
2122
2116
  * Number of directory entries that are buffered
@@ -2127,554 +2121,12 @@ declare module "fs" {
2127
2121
  bufferSize?: number;
2128
2122
  }
2129
2123
 
2130
- function opendirSync(path: string, options?: OpenDirOptions): Dir;
2124
+ export function opendirSync(path: string, options?: OpenDirOptions): Dir;
2131
2125
 
2132
- function opendir(path: string, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
2133
- function opendir(path: string, options: OpenDirOptions, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
2126
+ export function opendir(path: string, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
2127
+ export function opendir(path: string, options: OpenDirOptions, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
2134
2128
 
2135
- namespace opendir {
2129
+ export namespace opendir {
2136
2130
  function __promisify__(path: string, options?: OpenDirOptions): Promise<Dir>;
2137
2131
  }
2138
-
2139
- namespace promises {
2140
- interface FileHandle {
2141
- /**
2142
- * Gets the file descriptor for this file handle.
2143
- */
2144
- readonly fd: number;
2145
-
2146
- /**
2147
- * Asynchronously append data to a file, creating the file if it does not exist. The underlying file will _not_ be closed automatically.
2148
- * The `FileHandle` must have been opened for appending.
2149
- * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
2150
- * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
2151
- * If `encoding` is not supplied, the default of `'utf8'` is used.
2152
- * If `mode` is not supplied, the default of `0o666` is used.
2153
- * If `mode` is a string, it is parsed as an octal integer.
2154
- * If `flag` is not supplied, the default of `'a'` is used.
2155
- */
2156
- appendFile(data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
2157
-
2158
- /**
2159
- * Asynchronous fchown(2) - Change ownership of a file.
2160
- */
2161
- chown(uid: number, gid: number): Promise<void>;
2162
-
2163
- /**
2164
- * Asynchronous fchmod(2) - Change permissions of a file.
2165
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
2166
- */
2167
- chmod(mode: string | number): Promise<void>;
2168
-
2169
- /**
2170
- * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
2171
- */
2172
- datasync(): Promise<void>;
2173
-
2174
- /**
2175
- * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
2176
- */
2177
- sync(): Promise<void>;
2178
-
2179
- /**
2180
- * Asynchronously reads data from the file.
2181
- * The `FileHandle` must have been opened for reading.
2182
- * @param buffer The buffer that the data will be written to.
2183
- * @param offset The offset in the buffer at which to start writing.
2184
- * @param length The number of bytes to read.
2185
- * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
2186
- */
2187
- read<TBuffer extends Uint8Array>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesRead: number, buffer: TBuffer }>;
2188
-
2189
- /**
2190
- * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
2191
- * The `FileHandle` must have been opened for reading.
2192
- * @param options An object that may contain an optional flag.
2193
- * If a flag is not provided, it defaults to `'r'`.
2194
- */
2195
- readFile(options?: { encoding?: null, flag?: string | number } | null): Promise<Buffer>;
2196
-
2197
- /**
2198
- * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
2199
- * The `FileHandle` must have been opened for reading.
2200
- * @param options An object that may contain an optional flag.
2201
- * If a flag is not provided, it defaults to `'r'`.
2202
- */
2203
- readFile(options: { encoding: BufferEncoding, flag?: string | number } | BufferEncoding): Promise<string>;
2204
-
2205
- /**
2206
- * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
2207
- * The `FileHandle` must have been opened for reading.
2208
- * @param options An object that may contain an optional flag.
2209
- * If a flag is not provided, it defaults to `'r'`.
2210
- */
2211
- readFile(options?: { encoding?: string | null, flag?: string | number } | string | null): Promise<string | Buffer>;
2212
-
2213
- /**
2214
- * Asynchronous fstat(2) - Get file status.
2215
- */
2216
- stat(opts?: StatOptions & { bigint?: false }): Promise<Stats>;
2217
- stat(opts: StatOptions & { bigint: true }): Promise<BigIntStats>;
2218
- stat(opts?: StatOptions): Promise<Stats | BigIntStats>;
2219
-
2220
- /**
2221
- * Asynchronous ftruncate(2) - Truncate a file to a specified length.
2222
- * @param len If not specified, defaults to `0`.
2223
- */
2224
- truncate(len?: number): Promise<void>;
2225
-
2226
- /**
2227
- * Asynchronously change file timestamps of the file.
2228
- * @param atime The last access time. If a string is provided, it will be coerced to number.
2229
- * @param mtime The last modified time. If a string is provided, it will be coerced to number.
2230
- */
2231
- utimes(atime: string | number | Date, mtime: string | number | Date): Promise<void>;
2232
-
2233
- /**
2234
- * Asynchronously writes `buffer` to the file.
2235
- * The `FileHandle` must have been opened for writing.
2236
- * @param buffer The buffer that the data will be written to.
2237
- * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
2238
- * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
2239
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2240
- */
2241
- write<TBuffer extends Uint8Array>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesWritten: number, buffer: TBuffer }>;
2242
-
2243
- /**
2244
- * Asynchronously writes `string` to the file.
2245
- * The `FileHandle` must have been opened for writing.
2246
- * It is unsafe to call `write()` multiple times on the same file without waiting for the `Promise`
2247
- * to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
2248
- * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
2249
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2250
- * @param encoding The expected string encoding.
2251
- */
2252
- write(data: any, position?: number | null, encoding?: string | null): Promise<{ bytesWritten: number, buffer: string }>;
2253
-
2254
- /**
2255
- * Asynchronously writes data to a file, replacing the file if it already exists. The underlying file will _not_ be closed automatically.
2256
- * The `FileHandle` must have been opened for writing.
2257
- * It is unsafe to call `writeFile()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected).
2258
- * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
2259
- * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
2260
- * If `encoding` is not supplied, the default of `'utf8'` is used.
2261
- * If `mode` is not supplied, the default of `0o666` is used.
2262
- * If `mode` is a string, it is parsed as an octal integer.
2263
- * If `flag` is not supplied, the default of `'w'` is used.
2264
- */
2265
- writeFile(data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
2266
-
2267
- /**
2268
- * See `fs.writev` promisified version.
2269
- */
2270
- writev(buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<WriteVResult>;
2271
-
2272
- /**
2273
- * See `fs.readv` promisified version.
2274
- */
2275
- readv(buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<ReadVResult>;
2276
-
2277
- /**
2278
- * Asynchronous close(2) - close a `FileHandle`.
2279
- */
2280
- close(): Promise<void>;
2281
- }
2282
-
2283
- /**
2284
- * Asynchronously tests a user's permissions for the file specified by path.
2285
- * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
2286
- * URL support is _experimental_.
2287
- */
2288
- function access(path: PathLike, mode?: number): Promise<void>;
2289
-
2290
- /**
2291
- * Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it already exists.
2292
- * Node.js makes no guarantees about the atomicity of the copy operation.
2293
- * If an error occurs after the destination file has been opened for writing, Node.js will attempt
2294
- * to remove the destination.
2295
- * @param src A path to the source file.
2296
- * @param dest A path to the destination file.
2297
- * @param flags An optional integer that specifies the behavior of the copy operation. The only
2298
- * supported flag is `fs.constants.COPYFILE_EXCL`, which causes the copy operation to fail if
2299
- * `dest` already exists.
2300
- */
2301
- function copyFile(src: PathLike, dest: PathLike, flags?: number): Promise<void>;
2302
-
2303
- /**
2304
- * Asynchronous open(2) - open and possibly create a file.
2305
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2306
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not
2307
- * supplied, defaults to `0o666`.
2308
- */
2309
- function open(path: PathLike, flags: string | number, mode?: string | number): Promise<FileHandle>;
2310
-
2311
- /**
2312
- * Asynchronously reads data from the file referenced by the supplied `FileHandle`.
2313
- * @param handle A `FileHandle`.
2314
- * @param buffer The buffer that the data will be written to.
2315
- * @param offset The offset in the buffer at which to start writing.
2316
- * @param length The number of bytes to read.
2317
- * @param position The offset from the beginning of the file from which data should be read. If
2318
- * `null`, data will be read from the current position.
2319
- */
2320
- function read<TBuffer extends Uint8Array>(
2321
- handle: FileHandle,
2322
- buffer: TBuffer,
2323
- offset?: number | null,
2324
- length?: number | null,
2325
- position?: number | null,
2326
- ): Promise<{ bytesRead: number, buffer: TBuffer }>;
2327
-
2328
- /**
2329
- * Asynchronously writes `buffer` to the file referenced by the supplied `FileHandle`.
2330
- * It is unsafe to call `fsPromises.write()` multiple times on the same file without waiting for the `Promise`
2331
- * to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
2332
- * @param handle A `FileHandle`.
2333
- * @param buffer The buffer that the data will be written to.
2334
- * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
2335
- * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
2336
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2337
- */
2338
- function write<TBuffer extends Uint8Array>(
2339
- handle: FileHandle,
2340
- buffer: TBuffer,
2341
- offset?: number | null,
2342
- length?: number | null, position?: number | null): Promise<{ bytesWritten: number, buffer: TBuffer }>;
2343
-
2344
- /**
2345
- * Asynchronously writes `string` to the file referenced by the supplied `FileHandle`.
2346
- * It is unsafe to call `fsPromises.write()` multiple times on the same file without waiting for the `Promise`
2347
- * to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
2348
- * @param handle A `FileHandle`.
2349
- * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
2350
- * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
2351
- * @param encoding The expected string encoding.
2352
- */
2353
- function write(handle: FileHandle, string: any, position?: number | null, encoding?: string | null): Promise<{ bytesWritten: number, buffer: string }>;
2354
-
2355
- /**
2356
- * Asynchronous rename(2) - Change the name or location of a file or directory.
2357
- * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
2358
- * URL support is _experimental_.
2359
- * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
2360
- * URL support is _experimental_.
2361
- */
2362
- function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
2363
-
2364
- /**
2365
- * Asynchronous truncate(2) - Truncate a file to a specified length.
2366
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2367
- * @param len If not specified, defaults to `0`.
2368
- */
2369
- function truncate(path: PathLike, len?: number): Promise<void>;
2370
-
2371
- /**
2372
- * Asynchronous ftruncate(2) - Truncate a file to a specified length.
2373
- * @param handle A `FileHandle`.
2374
- * @param len If not specified, defaults to `0`.
2375
- */
2376
- function ftruncate(handle: FileHandle, len?: number): Promise<void>;
2377
-
2378
- /**
2379
- * Asynchronous rmdir(2) - delete a directory.
2380
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2381
- */
2382
- function rmdir(path: PathLike, options?: RmDirOptions): Promise<void>;
2383
-
2384
- /**
2385
- * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
2386
- * @param handle A `FileHandle`.
2387
- */
2388
- function fdatasync(handle: FileHandle): Promise<void>;
2389
-
2390
- /**
2391
- * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
2392
- * @param handle A `FileHandle`.
2393
- */
2394
- function fsync(handle: FileHandle): Promise<void>;
2395
-
2396
- /**
2397
- * Asynchronous mkdir(2) - create a directory.
2398
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2399
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
2400
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
2401
- */
2402
- function mkdir(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): Promise<string | undefined>;
2403
-
2404
- /**
2405
- * Asynchronous mkdir(2) - create a directory.
2406
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2407
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
2408
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
2409
- */
2410
- function mkdir(path: PathLike, options?: number | string | (MakeDirectoryOptions & { recursive?: false; }) | null): Promise<void>;
2411
-
2412
- /**
2413
- * Asynchronous mkdir(2) - create a directory.
2414
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2415
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
2416
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
2417
- */
2418
- function mkdir(path: PathLike, options?: number | string | MakeDirectoryOptions | null): Promise<string | undefined>;
2419
-
2420
- /**
2421
- * Asynchronous readdir(3) - read a directory.
2422
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2423
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2424
- */
2425
- function readdir(path: PathLike, options?: { encoding?: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): Promise<string[]>;
2426
-
2427
- /**
2428
- * Asynchronous readdir(3) - read a directory.
2429
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2430
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2431
- */
2432
- function readdir(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer"): Promise<Buffer[]>;
2433
-
2434
- /**
2435
- * Asynchronous readdir(3) - read a directory.
2436
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2437
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2438
- */
2439
- function readdir(path: PathLike, options?: { encoding?: string | null; withFileTypes?: false } | string | null): Promise<string[] | Buffer[]>;
2440
-
2441
- /**
2442
- * Asynchronous readdir(3) - read a directory.
2443
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2444
- * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
2445
- */
2446
- function readdir(path: PathLike, options: { encoding?: string | null; withFileTypes: true }): Promise<Dirent[]>;
2447
-
2448
- /**
2449
- * Asynchronous readlink(2) - read value of a symbolic link.
2450
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2451
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2452
- */
2453
- function readlink(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
2454
-
2455
- /**
2456
- * Asynchronous readlink(2) - read value of a symbolic link.
2457
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2458
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2459
- */
2460
- function readlink(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
2461
-
2462
- /**
2463
- * Asynchronous readlink(2) - read value of a symbolic link.
2464
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2465
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2466
- */
2467
- function readlink(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
2468
-
2469
- /**
2470
- * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
2471
- * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
2472
- * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
2473
- * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
2474
- * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
2475
- */
2476
- function symlink(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
2477
-
2478
- /**
2479
- * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
2480
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2481
- */
2482
- function lstat(path: PathLike, opts?: StatOptions & { bigint?: false }): Promise<Stats>;
2483
- function lstat(path: PathLike, opts: StatOptions & { bigint: true }): Promise<BigIntStats>;
2484
- function lstat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
2485
-
2486
- /**
2487
- * Asynchronous stat(2) - Get file status.
2488
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2489
- */
2490
- function stat(path: PathLike, opts?: StatOptions & { bigint?: false }): Promise<Stats>;
2491
- function stat(path: PathLike, opts: StatOptions & { bigint: true }): Promise<BigIntStats>;
2492
- function stat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
2493
-
2494
- /**
2495
- * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
2496
- * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
2497
- * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
2498
- */
2499
- function link(existingPath: PathLike, newPath: PathLike): Promise<void>;
2500
-
2501
- /**
2502
- * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
2503
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2504
- */
2505
- function unlink(path: PathLike): Promise<void>;
2506
-
2507
- /**
2508
- * Asynchronous fchmod(2) - Change permissions of a file.
2509
- * @param handle A `FileHandle`.
2510
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
2511
- */
2512
- function fchmod(handle: FileHandle, mode: string | number): Promise<void>;
2513
-
2514
- /**
2515
- * Asynchronous chmod(2) - Change permissions of a file.
2516
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2517
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
2518
- */
2519
- function chmod(path: PathLike, mode: string | number): Promise<void>;
2520
-
2521
- /**
2522
- * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
2523
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2524
- * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
2525
- */
2526
- function lchmod(path: PathLike, mode: string | number): Promise<void>;
2527
-
2528
- /**
2529
- * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
2530
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2531
- */
2532
- function lchown(path: PathLike, uid: number, gid: number): Promise<void>;
2533
-
2534
- /**
2535
- * Asynchronous fchown(2) - Change ownership of a file.
2536
- * @param handle A `FileHandle`.
2537
- */
2538
- function fchown(handle: FileHandle, uid: number, gid: number): Promise<void>;
2539
-
2540
- /**
2541
- * Asynchronous chown(2) - Change ownership of a file.
2542
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2543
- */
2544
- function chown(path: PathLike, uid: number, gid: number): Promise<void>;
2545
-
2546
- /**
2547
- * Asynchronously change file timestamps of the file referenced by the supplied path.
2548
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2549
- * @param atime The last access time. If a string is provided, it will be coerced to number.
2550
- * @param mtime The last modified time. If a string is provided, it will be coerced to number.
2551
- */
2552
- function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
2553
-
2554
- /**
2555
- * Asynchronously change file timestamps of the file referenced by the supplied `FileHandle`.
2556
- * @param handle A `FileHandle`.
2557
- * @param atime The last access time. If a string is provided, it will be coerced to number.
2558
- * @param mtime The last modified time. If a string is provided, it will be coerced to number.
2559
- */
2560
- function futimes(handle: FileHandle, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
2561
-
2562
- /**
2563
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
2564
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2565
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2566
- */
2567
- function realpath(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
2568
-
2569
- /**
2570
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
2571
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2572
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2573
- */
2574
- function realpath(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
2575
-
2576
- /**
2577
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
2578
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2579
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2580
- */
2581
- function realpath(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
2582
-
2583
- /**
2584
- * Asynchronously creates a unique temporary directory.
2585
- * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
2586
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2587
- */
2588
- function mkdtemp(prefix: string, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
2589
-
2590
- /**
2591
- * Asynchronously creates a unique temporary directory.
2592
- * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
2593
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2594
- */
2595
- function mkdtemp(prefix: string, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
2596
-
2597
- /**
2598
- * Asynchronously creates a unique temporary directory.
2599
- * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
2600
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2601
- */
2602
- function mkdtemp(prefix: string, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
2603
-
2604
- /**
2605
- * Asynchronously writes data to a file, replacing the file if it already exists.
2606
- * It is unsafe to call `fsPromises.writeFile()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected).
2607
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2608
- * URL support is _experimental_.
2609
- * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
2610
- * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
2611
- * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
2612
- * If `encoding` is not supplied, the default of `'utf8'` is used.
2613
- * If `mode` is not supplied, the default of `0o666` is used.
2614
- * If `mode` is a string, it is parsed as an octal integer.
2615
- * If `flag` is not supplied, the default of `'w'` is used.
2616
- */
2617
- function writeFile(path: PathLike | FileHandle, data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
2618
-
2619
- /**
2620
- * Asynchronously append data to a file, creating the file if it does not exist.
2621
- * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
2622
- * URL support is _experimental_.
2623
- * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
2624
- * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
2625
- * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
2626
- * If `encoding` is not supplied, the default of `'utf8'` is used.
2627
- * If `mode` is not supplied, the default of `0o666` is used.
2628
- * If `mode` is a string, it is parsed as an octal integer.
2629
- * If `flag` is not supplied, the default of `'a'` is used.
2630
- */
2631
- function appendFile(path: PathLike | FileHandle, data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
2632
-
2633
- /**
2634
- * Asynchronously reads the entire contents of a file.
2635
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2636
- * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
2637
- * @param options An object that may contain an optional flag.
2638
- * If a flag is not provided, it defaults to `'r'`.
2639
- */
2640
- function readFile(path: PathLike | FileHandle, options?: { encoding?: null, flag?: string | number } | null): Promise<Buffer>;
2641
-
2642
- /**
2643
- * Asynchronously reads the entire contents of a file.
2644
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2645
- * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
2646
- * @param options An object that may contain an optional flag.
2647
- * If a flag is not provided, it defaults to `'r'`.
2648
- */
2649
- function readFile(path: PathLike | FileHandle, options: { encoding: BufferEncoding, flag?: string | number } | BufferEncoding): Promise<string>;
2650
-
2651
- /**
2652
- * Asynchronously reads the entire contents of a file.
2653
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2654
- * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
2655
- * @param options An object that may contain an optional flag.
2656
- * If a flag is not provided, it defaults to `'r'`.
2657
- */
2658
- function readFile(path: PathLike | FileHandle, options?: { encoding?: string | null, flag?: string | number } | string | null): Promise<string | Buffer>;
2659
-
2660
- function opendir(path: string, options?: OpenDirOptions): Promise<Dir>;
2661
- }
2662
-
2663
- interface BigIntStats extends StatsBase<bigint> {
2664
- }
2665
-
2666
- class BigIntStats {
2667
- atimeNs: bigint;
2668
- mtimeNs: bigint;
2669
- ctimeNs: bigint;
2670
- birthtimeNs: bigint;
2671
- }
2672
-
2673
- interface BigIntOptions {
2674
- bigint: true;
2675
- }
2676
-
2677
- interface StatOptions {
2678
- bigint: boolean;
2679
- }
2680
2132
  }