@types/node 18.16.3 → 20.1.0

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 (96) hide show
  1. node/README.md +1 -1
  2. node/assert.d.ts +71 -75
  3. node/async_hooks.d.ts +62 -42
  4. node/buffer.d.ts +127 -99
  5. node/child_process.d.ts +50 -54
  6. node/cluster.d.ts +12 -12
  7. node/console.d.ts +5 -5
  8. node/crypto.d.ts +209 -220
  9. node/dgram.d.ts +15 -15
  10. node/diagnostics_channel.d.ts +25 -26
  11. node/dns/promises.d.ts +6 -6
  12. node/dns.d.ts +24 -16
  13. node/domain.d.ts +4 -4
  14. node/events.d.ts +60 -60
  15. node/fs/promises.d.ts +78 -48
  16. node/fs.d.ts +117 -81
  17. node/http.d.ts +158 -147
  18. node/http2.d.ts +42 -46
  19. node/https.d.ts +52 -153
  20. node/index.d.ts +1 -1
  21. node/inspector.d.ts +10 -3
  22. node/module.d.ts +5 -4
  23. node/net.d.ts +21 -18
  24. node/os.d.ts +22 -18
  25. node/package.json +2 -2
  26. node/path.d.ts +4 -4
  27. node/perf_hooks.d.ts +28 -15
  28. node/process.d.ts +43 -46
  29. node/punycode.d.ts +1 -1
  30. node/querystring.d.ts +5 -5
  31. node/readline/promises.d.ts +6 -4
  32. node/readline.d.ts +15 -15
  33. node/repl.d.ts +9 -9
  34. node/stream/consumers.d.ts +1 -1
  35. node/stream.d.ts +88 -136
  36. node/string_decoder.d.ts +6 -6
  37. node/test.d.ts +423 -186
  38. node/timers/promises.d.ts +3 -3
  39. node/timers.d.ts +2 -2
  40. node/tls.d.ts +24 -16
  41. node/trace_events.d.ts +20 -9
  42. node/ts4.8/assert.d.ts +71 -75
  43. node/ts4.8/async_hooks.d.ts +62 -42
  44. node/ts4.8/buffer.d.ts +127 -99
  45. node/ts4.8/child_process.d.ts +50 -54
  46. node/ts4.8/cluster.d.ts +12 -12
  47. node/ts4.8/console.d.ts +5 -5
  48. node/ts4.8/crypto.d.ts +209 -220
  49. node/ts4.8/dgram.d.ts +15 -15
  50. node/ts4.8/diagnostics_channel.d.ts +25 -26
  51. node/ts4.8/dns/promises.d.ts +6 -6
  52. node/ts4.8/dns.d.ts +24 -16
  53. node/ts4.8/domain.d.ts +4 -4
  54. node/ts4.8/events.d.ts +60 -60
  55. node/ts4.8/fs/promises.d.ts +96 -45
  56. node/ts4.8/fs.d.ts +203 -67
  57. node/ts4.8/globals.d.ts +29 -28
  58. node/ts4.8/http.d.ts +198 -126
  59. node/ts4.8/http2.d.ts +42 -46
  60. node/ts4.8/https.d.ts +52 -153
  61. node/ts4.8/inspector.d.ts +10 -3
  62. node/ts4.8/module.d.ts +5 -4
  63. node/ts4.8/net.d.ts +24 -21
  64. node/ts4.8/os.d.ts +22 -18
  65. node/ts4.8/path.d.ts +4 -4
  66. node/ts4.8/perf_hooks.d.ts +28 -15
  67. node/ts4.8/process.d.ts +43 -46
  68. node/ts4.8/punycode.d.ts +1 -1
  69. node/ts4.8/querystring.d.ts +5 -5
  70. node/ts4.8/readline/promises.d.ts +6 -4
  71. node/ts4.8/readline.d.ts +15 -15
  72. node/ts4.8/repl.d.ts +9 -9
  73. node/ts4.8/stream/consumers.d.ts +1 -1
  74. node/ts4.8/stream.d.ts +91 -139
  75. node/ts4.8/string_decoder.d.ts +6 -6
  76. node/ts4.8/test.d.ts +423 -186
  77. node/ts4.8/timers/promises.d.ts +3 -3
  78. node/ts4.8/timers.d.ts +9 -2
  79. node/ts4.8/tls.d.ts +24 -16
  80. node/ts4.8/trace_events.d.ts +20 -9
  81. node/ts4.8/tty.d.ts +4 -5
  82. node/ts4.8/url.d.ts +26 -36
  83. node/ts4.8/util.d.ts +143 -116
  84. node/ts4.8/v8.d.ts +110 -16
  85. node/ts4.8/vm.d.ts +292 -42
  86. node/ts4.8/wasi.d.ts +13 -19
  87. node/ts4.8/worker_threads.d.ts +32 -34
  88. node/ts4.8/zlib.d.ts +11 -11
  89. node/tty.d.ts +4 -5
  90. node/url.d.ts +26 -36
  91. node/util.d.ts +146 -111
  92. node/v8.d.ts +110 -16
  93. node/vm.d.ts +292 -42
  94. node/wasi.d.ts +13 -19
  95. node/worker_threads.d.ts +32 -34
  96. node/zlib.d.ts +11 -11
node/ts4.8/fs.d.ts CHANGED
@@ -1,22 +1,22 @@
1
1
  /**
2
- * The `fs` module enables interacting with the file system in a
2
+ * The `node:fs` module enables interacting with the file system in a
3
3
  * way modeled on standard POSIX functions.
4
4
  *
5
5
  * To use the promise-based APIs:
6
6
  *
7
7
  * ```js
8
- * import * as fs from 'fs/promises';
8
+ * import * as fs from 'node:fs/promises';
9
9
  * ```
10
10
  *
11
11
  * To use the callback and sync APIs:
12
12
  *
13
13
  * ```js
14
- * import * as fs from 'fs';
14
+ * import * as fs from 'node:fs';
15
15
  * ```
16
16
  *
17
17
  * All file system operations have synchronous, callback, and promise-based
18
18
  * forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).
19
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/fs.js)
19
+ * @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/fs.js)
20
20
  */
21
21
  declare module 'fs' {
22
22
  import * as stream from 'node:stream';
@@ -73,7 +73,7 @@ declare module 'fs' {
73
73
  /**
74
74
  * A `fs.Stats` object provides information about a file.
75
75
  *
76
- * Objects returned from {@link stat}, {@link lstat} and {@link fstat} and
76
+ * Objects returned from {@link stat}, {@link lstat}, {@link fstat}, and
77
77
  * their synchronous counterparts are of this type.
78
78
  * If `bigint` in the `options` passed to those methods is true, the numeric values
79
79
  * will be `bigint` instead of `number`, and the object will contain additional
@@ -131,6 +131,36 @@ declare module 'fs' {
131
131
  * @since v0.1.21
132
132
  */
133
133
  export class Stats {}
134
+ export interface StatsFsBase<T> {
135
+ /** Type of file system. */
136
+ type: T;
137
+ /** Optimal transfer block size. */
138
+ bsize: T;
139
+ /** Total data blocks in file system. */
140
+ blocks: T;
141
+ /** Free blocks in file system. */
142
+ bfree: T;
143
+ /** Available blocks for unprivileged users */
144
+ bavail: T;
145
+ /** Total file nodes in file system. */
146
+ files: T;
147
+ /** Free file nodes in file system. */
148
+ ffree: T;
149
+ }
150
+ export interface StatsFs extends StatsFsBase<number> {}
151
+ /**
152
+ * Provides information about a mounted file system
153
+ *
154
+ * Objects returned from {@link statfs} and {@link statfsSync} are of this type.
155
+ * If `bigint` in the `options` passed to those methods is true, the numeric values
156
+ * will be `bigint` instead of `number`.
157
+ * @since v18.15.0
158
+ */
159
+ export class StatsFs {}
160
+ export interface BigIntStatsFs extends StatsFsBase<bigint> {}
161
+ export interface StatFsOptions {
162
+ bigint?: boolean | undefined;
163
+ }
134
164
  /**
135
165
  * A representation of a directory entry, which can be a file or a subdirectory
136
166
  * within the directory, as returned by reading from an `fs.Dir`. The
@@ -191,7 +221,7 @@ declare module 'fs' {
191
221
  * Created by {@link opendir}, {@link opendirSync}, or `fsPromises.opendir()`.
192
222
  *
193
223
  * ```js
194
- * import { opendir } from 'fs/promises';
224
+ * import { opendir } from 'node:fs/promises';
195
225
  *
196
226
  * try {
197
227
  * const dir = await opendir('./');
@@ -494,7 +524,7 @@ declare module 'fs' {
494
524
  * See also: [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html).
495
525
  *
496
526
  * ```js
497
- * import { rename } from 'fs';
527
+ * import { rename } from 'node:fs';
498
528
  *
499
529
  * rename('oldFile.txt', 'newFile.txt', (err) => {
500
530
  * if (err) throw err;
@@ -527,7 +557,7 @@ declare module 'fs' {
527
557
  * first argument. In this case, `fs.ftruncate()` is called.
528
558
  *
529
559
  * ```js
530
- * import { truncate } from 'fs';
560
+ * import { truncate } from 'node:fs';
531
561
  * // Assuming that 'path/file.txt' is a regular file.
532
562
  * truncate('path/file.txt', (err) => {
533
563
  * if (err) throw err;
@@ -579,7 +609,7 @@ declare module 'fs' {
579
609
  * file:
580
610
  *
581
611
  * ```js
582
- * import { open, close, ftruncate } from 'fs';
612
+ * import { open, close, ftruncate } from 'node:fs';
583
613
  *
584
614
  * function closeFd(fd) {
585
615
  * close(fd, (err) => {
@@ -736,7 +766,7 @@ declare module 'fs' {
736
766
  * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail.
737
767
  *
738
768
  * ```js
739
- * import { chmod } from 'fs';
769
+ * import { chmod } from 'node:fs';
740
770
  *
741
771
  * chmod('my_file.txt', 0o775, (err) => {
742
772
  * if (err) throw err;
@@ -818,7 +848,10 @@ declare module 'fs' {
818
848
  *
819
849
  * In case of an error, the `err.code` will be one of `Common System Errors`.
820
850
  *
821
- * Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended.
851
+ * {@link stat} follows symbolic links. Use {@link lstat} to look at the
852
+ * links themselves.
853
+ *
854
+ * Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended.
822
855
  * Instead, user code should open/read/write the file directly and handle the
823
856
  * error raised if the file is not available.
824
857
  *
@@ -835,7 +868,7 @@ declare module 'fs' {
835
868
  * The next program will check for the stats of the given paths:
836
869
  *
837
870
  * ```js
838
- * import { stat } from 'fs';
871
+ * import { stat } from 'node:fs';
839
872
  *
840
873
  * const pathsToCheck = ['./txtDir', './txtDir/file.txt'];
841
874
  *
@@ -1081,6 +1114,72 @@ declare module 'fs' {
1081
1114
  ): Promise<BigIntStats>;
1082
1115
  function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
1083
1116
  }
1117
+ /**
1118
+ * Asynchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which
1119
+ * contains `path`. The callback gets two arguments `(err, stats)` where `stats`is an `fs.StatFs` object.
1120
+ *
1121
+ * In case of an error, the `err.code` will be one of `Common System Errors`.
1122
+ * @since v19.6.0, v18.15.0
1123
+ * @param path A path to an existing file or directory on the file system to be queried.
1124
+ */
1125
+ export function statfs(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void): void;
1126
+ export function statfs(
1127
+ path: PathLike,
1128
+ options:
1129
+ | (StatFsOptions & {
1130
+ bigint?: false | undefined;
1131
+ })
1132
+ | undefined,
1133
+ callback: (err: NodeJS.ErrnoException | null, stats: StatsFs) => void
1134
+ ): void;
1135
+ export function statfs(
1136
+ path: PathLike,
1137
+ options: StatFsOptions & {
1138
+ bigint: true;
1139
+ },
1140
+ callback: (err: NodeJS.ErrnoException | null, stats: BigIntStatsFs) => void
1141
+ ): void;
1142
+ export function statfs(path: PathLike, options: StatFsOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: StatsFs | BigIntStatsFs) => void): void;
1143
+ export namespace statfs {
1144
+ /**
1145
+ * Asynchronous statfs(2) - Returns information about the mounted file system which contains path. The callback gets two arguments (err, stats) where stats is an <fs.StatFs> object.
1146
+ * @param path A path to an existing file or directory on the file system to be queried.
1147
+ */
1148
+ function __promisify__(
1149
+ path: PathLike,
1150
+ options?: StatFsOptions & {
1151
+ bigint?: false | undefined;
1152
+ }
1153
+ ): Promise<StatsFs>;
1154
+ function __promisify__(
1155
+ path: PathLike,
1156
+ options: StatFsOptions & {
1157
+ bigint: true;
1158
+ }
1159
+ ): Promise<BigIntStatsFs>;
1160
+ function __promisify__(path: PathLike, options?: StatFsOptions): Promise<StatsFs | BigIntStatsFs>;
1161
+ }
1162
+ /**
1163
+ * Synchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which
1164
+ * contains `path`.
1165
+ *
1166
+ * In case of an error, the `err.code` will be one of `Common System Errors`.
1167
+ * @since v19.6.0, v18.15.0
1168
+ * @param path A path to an existing file or directory on the file system to be queried.
1169
+ */
1170
+ export function statfsSync(
1171
+ path: PathLike,
1172
+ options?: StatFsOptions & {
1173
+ bigint?: false | undefined;
1174
+ }
1175
+ ): StatsFs;
1176
+ export function statfsSync(
1177
+ path: PathLike,
1178
+ options: StatFsOptions & {
1179
+ bigint: true;
1180
+ }
1181
+ ): BigIntStatsFs;
1182
+ export function statfsSync(path: PathLike, options?: StatFsOptions): StatsFs | BigIntStatsFs;
1084
1183
  /**
1085
1184
  * Synchronous lstat(2) - Get file status. Does not dereference symbolic links.
1086
1185
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -1114,14 +1213,14 @@ declare module 'fs' {
1114
1213
  *
1115
1214
  * The `type` argument is only available on Windows and ignored on other platforms.
1116
1215
  * It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is
1117
- * not set, Node.js will autodetect `target` type and use `'file'` or `'dir'`. If
1118
- * the `target` does not exist, `'file'` will be used. Windows junction points
1216
+ * not a string, Node.js will autodetect `target` type and use `'file'` or `'dir'`.
1217
+ * If the `target` does not exist, `'file'` will be used. Windows junction points
1119
1218
  * require the destination path to be absolute. When using `'junction'`, the`target` argument will automatically be normalized to absolute path.
1120
1219
  *
1121
- * Relative targets are relative to the links parent directory.
1220
+ * Relative targets are relative to the link's parent directory.
1122
1221
  *
1123
1222
  * ```js
1124
- * import { symlink } from 'fs';
1223
+ * import { symlink } from 'node:fs';
1125
1224
  *
1126
1225
  * symlink('./mew', './mewtwo', callback);
1127
1226
  * ```
@@ -1136,6 +1235,7 @@ declare module 'fs' {
1136
1235
  * └── mewtwo -> ./mew
1137
1236
  * ```
1138
1237
  * @since v0.1.31
1238
+ * @param [type='null']
1139
1239
  */
1140
1240
  export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: NoParamCallback): void;
1141
1241
  /**
@@ -1161,6 +1261,7 @@ declare module 'fs' {
1161
1261
  * For detailed information, see the documentation of the asynchronous version of
1162
1262
  * this API: {@link symlink}.
1163
1263
  * @since v0.1.31
1264
+ * @param [type='null']
1164
1265
  */
1165
1266
  export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
1166
1267
  /**
@@ -1238,7 +1339,7 @@ declare module 'fs' {
1238
1339
  */
1239
1340
  export function readlinkSync(path: PathLike, options?: EncodingOption): string | Buffer;
1240
1341
  /**
1241
- * Asynchronously computes the canonical pathname by resolving `.`, `..` and
1342
+ * Asynchronously computes the canonical pathname by resolving `.`, `..`, and
1242
1343
  * symbolic links.
1243
1344
  *
1244
1345
  * A canonical pathname is not necessarily unique. Hard links and bind mounts can
@@ -1352,7 +1453,7 @@ declare module 'fs' {
1352
1453
  * possible exception are given to the completion callback.
1353
1454
  *
1354
1455
  * ```js
1355
- * import { unlink } from 'fs';
1456
+ * import { unlink } from 'node:fs';
1356
1457
  * // Assuming that 'path/file.txt' is a regular file.
1357
1458
  * unlink('path/file.txt', (err) => {
1358
1459
  * if (err) throw err;
@@ -1507,7 +1608,7 @@ declare module 'fs' {
1507
1608
  * when `recursive` is false.
1508
1609
  *
1509
1610
  * ```js
1510
- * import { mkdir } from 'fs';
1611
+ * import { mkdir } from 'node:fs';
1511
1612
  *
1512
1613
  * // Creates /tmp/a/apple, regardless of whether `/tmp` and /tmp/a exist.
1513
1614
  * mkdir('/tmp/a/apple', { recursive: true }, (err) => {
@@ -1519,7 +1620,7 @@ declare module 'fs' {
1519
1620
  * result in an error:
1520
1621
  *
1521
1622
  * ```js
1522
- * import { mkdir } from 'fs';
1623
+ * import { mkdir } from 'node:fs';
1523
1624
  *
1524
1625
  * mkdir('/', { recursive: true }, (err) => {
1525
1626
  * // => [Error: EPERM: operation not permitted, mkdir 'C:\']
@@ -1651,9 +1752,11 @@ declare module 'fs' {
1651
1752
  * object with an `encoding` property specifying the character encoding to use.
1652
1753
  *
1653
1754
  * ```js
1654
- * import { mkdtemp } from 'fs';
1755
+ * import { mkdtemp } from 'node:fs';
1756
+ * import { join } from 'node:path';
1757
+ * import { tmpdir } from 'node:os';
1655
1758
  *
1656
- * mkdtemp(path.join(os.tmpdir(), 'foo-'), (err, directory) => {
1759
+ * mkdtemp(join(tmpdir(), 'foo-'), (err, directory) => {
1657
1760
  * if (err) throw err;
1658
1761
  * console.log(directory);
1659
1762
  * // Prints: /tmp/foo-itXde2 or C:\Users\...\AppData\Local\Temp\foo-itXde2
@@ -1663,11 +1766,11 @@ declare module 'fs' {
1663
1766
  * The `fs.mkdtemp()` method will append the six randomly selected characters
1664
1767
  * directly to the `prefix` string. For instance, given a directory `/tmp`, if the
1665
1768
  * intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator
1666
- * (`require('path').sep`).
1769
+ * (`require('node:path').sep`).
1667
1770
  *
1668
1771
  * ```js
1669
- * import { tmpdir } from 'os';
1670
- * import { mkdtemp } from 'fs';
1772
+ * import { tmpdir } from 'node:os';
1773
+ * import { mkdtemp } from 'node:fs';
1671
1774
  *
1672
1775
  * // The parent directory for the new temporary directory
1673
1776
  * const tmpDir = tmpdir();
@@ -1682,7 +1785,7 @@ declare module 'fs' {
1682
1785
  * });
1683
1786
  *
1684
1787
  * // This method is *CORRECT*:
1685
- * import { sep } from 'path';
1788
+ * import { sep } from 'node:path';
1686
1789
  * mkdtemp(`${tmpDir}${sep}`, (err, directory) => {
1687
1790
  * if (err) throw err;
1688
1791
  * console.log(directory);
@@ -1781,6 +1884,7 @@ declare module 'fs' {
1781
1884
  | {
1782
1885
  encoding: BufferEncoding | null;
1783
1886
  withFileTypes?: false | undefined;
1887
+ recursive?: boolean | undefined;
1784
1888
  }
1785
1889
  | BufferEncoding
1786
1890
  | undefined
@@ -1798,6 +1902,7 @@ declare module 'fs' {
1798
1902
  | {
1799
1903
  encoding: 'buffer';
1800
1904
  withFileTypes?: false | undefined;
1905
+ recursive?: boolean | undefined;
1801
1906
  }
1802
1907
  | 'buffer',
1803
1908
  callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void
@@ -1812,6 +1917,7 @@ declare module 'fs' {
1812
1917
  options:
1813
1918
  | (ObjectEncodingOptions & {
1814
1919
  withFileTypes?: false | undefined;
1920
+ recursive?: boolean | undefined;
1815
1921
  })
1816
1922
  | BufferEncoding
1817
1923
  | undefined
@@ -1832,6 +1938,7 @@ declare module 'fs' {
1832
1938
  path: PathLike,
1833
1939
  options: ObjectEncodingOptions & {
1834
1940
  withFileTypes: true;
1941
+ recursive?: boolean | undefined;
1835
1942
  },
1836
1943
  callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void
1837
1944
  ): void;
@@ -1847,6 +1954,7 @@ declare module 'fs' {
1847
1954
  | {
1848
1955
  encoding: BufferEncoding | null;
1849
1956
  withFileTypes?: false | undefined;
1957
+ recursive?: boolean | undefined;
1850
1958
  }
1851
1959
  | BufferEncoding
1852
1960
  | null
@@ -1863,6 +1971,7 @@ declare module 'fs' {
1863
1971
  | {
1864
1972
  encoding: 'buffer';
1865
1973
  withFileTypes?: false | undefined;
1974
+ recursive?: boolean | undefined;
1866
1975
  }
1867
1976
  ): Promise<Buffer[]>;
1868
1977
  /**
@@ -1875,6 +1984,7 @@ declare module 'fs' {
1875
1984
  options?:
1876
1985
  | (ObjectEncodingOptions & {
1877
1986
  withFileTypes?: false | undefined;
1987
+ recursive?: boolean | undefined;
1878
1988
  })
1879
1989
  | BufferEncoding
1880
1990
  | null
@@ -1888,6 +1998,7 @@ declare module 'fs' {
1888
1998
  path: PathLike,
1889
1999
  options: ObjectEncodingOptions & {
1890
2000
  withFileTypes: true;
2001
+ recursive?: boolean | undefined;
1891
2002
  }
1892
2003
  ): Promise<Dirent[]>;
1893
2004
  }
@@ -1910,6 +2021,7 @@ declare module 'fs' {
1910
2021
  | {
1911
2022
  encoding: BufferEncoding | null;
1912
2023
  withFileTypes?: false | undefined;
2024
+ recursive?: boolean | undefined;
1913
2025
  }
1914
2026
  | BufferEncoding
1915
2027
  | null
@@ -1925,6 +2037,7 @@ declare module 'fs' {
1925
2037
  | {
1926
2038
  encoding: 'buffer';
1927
2039
  withFileTypes?: false | undefined;
2040
+ recursive?: boolean | undefined;
1928
2041
  }
1929
2042
  | 'buffer'
1930
2043
  ): Buffer[];
@@ -1938,6 +2051,7 @@ declare module 'fs' {
1938
2051
  options?:
1939
2052
  | (ObjectEncodingOptions & {
1940
2053
  withFileTypes?: false | undefined;
2054
+ recursive?: boolean | undefined;
1941
2055
  })
1942
2056
  | BufferEncoding
1943
2057
  | null
@@ -1951,6 +2065,7 @@ declare module 'fs' {
1951
2065
  path: PathLike,
1952
2066
  options: ObjectEncodingOptions & {
1953
2067
  withFileTypes: true;
2068
+ recursive?: boolean | undefined;
1954
2069
  }
1955
2070
  ): Dirent[];
1956
2071
  /**
@@ -2010,7 +2125,6 @@ declare module 'fs' {
2010
2125
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2011
2126
  */
2012
2127
  export function open(path: PathLike, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
2013
-
2014
2128
  export namespace open {
2015
2129
  /**
2016
2130
  * Asynchronous open(2) - open and possibly create a file.
@@ -2035,7 +2149,7 @@ declare module 'fs' {
2035
2149
  * The `atime` and `mtime` arguments follow these rules:
2036
2150
  *
2037
2151
  * * Values can be either numbers representing Unix epoch time in seconds,`Date`s, or a numeric string like `'123456789.0'`.
2038
- * * If the value can not be converted to a number, or is `NaN`, `Infinity` or`-Infinity`, an `Error` will be thrown.
2152
+ * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or`-Infinity`, an `Error` will be thrown.
2039
2153
  * @since v0.4.2
2040
2154
  */
2041
2155
  export function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
@@ -2121,6 +2235,9 @@ declare module 'fs' {
2121
2235
  * The kernel ignores the position argument and always appends the data to
2122
2236
  * the end of the file.
2123
2237
  * @since v0.0.2
2238
+ * @param [offset=0]
2239
+ * @param [length=buffer.byteLength - offset]
2240
+ * @param [position='null']
2124
2241
  */
2125
2242
  export function write<TBuffer extends NodeJS.ArrayBufferView>(
2126
2243
  fd: number,
@@ -2225,6 +2342,9 @@ declare module 'fs' {
2225
2342
  * For detailed information, see the documentation of the asynchronous version of
2226
2343
  * this API: {@link write}.
2227
2344
  * @since v0.1.21
2345
+ * @param [offset=0]
2346
+ * @param [length=buffer.byteLength - offset]
2347
+ * @param [position='null']
2228
2348
  * @return The number of bytes written.
2229
2349
  */
2230
2350
  export function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
@@ -2330,6 +2450,7 @@ declare module 'fs' {
2330
2450
  * For detailed information, see the documentation of the asynchronous version of
2331
2451
  * this API: {@link read}.
2332
2452
  * @since v0.1.21
2453
+ * @param [position='null']
2333
2454
  */
2334
2455
  export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: ReadPosition | null): number;
2335
2456
  /**
@@ -2341,7 +2462,7 @@ declare module 'fs' {
2341
2462
  * Asynchronously reads the entire contents of a file.
2342
2463
  *
2343
2464
  * ```js
2344
- * import { readFile } from 'fs';
2465
+ * import { readFile } from 'node:fs';
2345
2466
  *
2346
2467
  * readFile('/etc/passwd', (err, data) => {
2347
2468
  * if (err) throw err;
@@ -2357,7 +2478,7 @@ declare module 'fs' {
2357
2478
  * If `options` is a string, then it specifies the encoding:
2358
2479
  *
2359
2480
  * ```js
2360
- * import { readFile } from 'fs';
2481
+ * import { readFile } from 'node:fs';
2361
2482
  *
2362
2483
  * readFile('/etc/passwd', 'utf8', callback);
2363
2484
  * ```
@@ -2367,7 +2488,7 @@ declare module 'fs' {
2367
2488
  * will be returned.
2368
2489
  *
2369
2490
  * ```js
2370
- * import { readFile } from 'fs';
2491
+ * import { readFile } from 'node:fs';
2371
2492
  *
2372
2493
  * // macOS, Linux, and Windows
2373
2494
  * readFile('<directory>', (err, data) => {
@@ -2384,7 +2505,7 @@ declare module 'fs' {
2384
2505
  * request is aborted the callback is called with an `AbortError`:
2385
2506
  *
2386
2507
  * ```js
2387
- * import { readFile } from 'fs';
2508
+ * import { readFile } from 'node:fs';
2388
2509
  *
2389
2510
  * const controller = new AbortController();
2390
2511
  * const signal = controller.signal;
@@ -2517,7 +2638,7 @@ declare module 'fs' {
2517
2638
  * Similar to {@link readFile}, when the path is a directory, the behavior of`fs.readFileSync()` is platform-specific.
2518
2639
  *
2519
2640
  * ```js
2520
- * import { readFileSync } from 'fs';
2641
+ * import { readFileSync } from 'node:fs';
2521
2642
  *
2522
2643
  * // macOS, Linux, and Windows
2523
2644
  * readFileSync('<directory>');
@@ -2588,8 +2709,8 @@ declare module 'fs' {
2588
2709
  * The `mode` option only affects the newly created file. See {@link open} for more details.
2589
2710
  *
2590
2711
  * ```js
2591
- * import { writeFile } from 'fs';
2592
- * import { Buffer } from 'buffer';
2712
+ * import { writeFile } from 'node:fs';
2713
+ * import { Buffer } from 'node:buffer';
2593
2714
  *
2594
2715
  * const data = new Uint8Array(Buffer.from('Hello Node.js'));
2595
2716
  * writeFile('message.txt', data, (err) => {
@@ -2601,7 +2722,7 @@ declare module 'fs' {
2601
2722
  * If `options` is a string, then it specifies the encoding:
2602
2723
  *
2603
2724
  * ```js
2604
- * import { writeFile } from 'fs';
2725
+ * import { writeFile } from 'node:fs';
2605
2726
  *
2606
2727
  * writeFile('message.txt', 'Hello Node.js', 'utf8', callback);
2607
2728
  * ```
@@ -2619,8 +2740,8 @@ declare module 'fs' {
2619
2740
  * to be written.
2620
2741
  *
2621
2742
  * ```js
2622
- * import { writeFile } from 'fs';
2623
- * import { Buffer } from 'buffer';
2743
+ * import { writeFile } from 'node:fs';
2744
+ * import { Buffer } from 'node:buffer';
2624
2745
  *
2625
2746
  * const controller = new AbortController();
2626
2747
  * const { signal } = controller;
@@ -2678,7 +2799,7 @@ declare module 'fs' {
2678
2799
  * The `mode` option only affects the newly created file. See {@link open} for more details.
2679
2800
  *
2680
2801
  * ```js
2681
- * import { appendFile } from 'fs';
2802
+ * import { appendFile } from 'node:fs';
2682
2803
  *
2683
2804
  * appendFile('message.txt', 'data to append', (err) => {
2684
2805
  * if (err) throw err;
@@ -2689,7 +2810,7 @@ declare module 'fs' {
2689
2810
  * If `options` is a string, then it specifies the encoding:
2690
2811
  *
2691
2812
  * ```js
2692
- * import { appendFile } from 'fs';
2813
+ * import { appendFile } from 'node:fs';
2693
2814
  *
2694
2815
  * appendFile('message.txt', 'data to append', 'utf8', callback);
2695
2816
  * ```
@@ -2699,7 +2820,7 @@ declare module 'fs' {
2699
2820
  * not be closed automatically.
2700
2821
  *
2701
2822
  * ```js
2702
- * import { open, close, appendFile } from 'fs';
2823
+ * import { open, close, appendFile } from 'node:fs';
2703
2824
  *
2704
2825
  * function closeFd(fd) {
2705
2826
  * close(fd, (err) => {
@@ -2754,7 +2875,7 @@ declare module 'fs' {
2754
2875
  * The `mode` option only affects the newly created file. See {@link open} for more details.
2755
2876
  *
2756
2877
  * ```js
2757
- * import { appendFileSync } from 'fs';
2878
+ * import { appendFileSync } from 'node:fs';
2758
2879
  *
2759
2880
  * try {
2760
2881
  * appendFileSync('message.txt', 'data to append');
@@ -2767,7 +2888,7 @@ declare module 'fs' {
2767
2888
  * If `options` is a string, then it specifies the encoding:
2768
2889
  *
2769
2890
  * ```js
2770
- * import { appendFileSync } from 'fs';
2891
+ * import { appendFileSync } from 'node:fs';
2771
2892
  *
2772
2893
  * appendFileSync('message.txt', 'data to append', 'utf8');
2773
2894
  * ```
@@ -2777,7 +2898,7 @@ declare module 'fs' {
2777
2898
  * not be closed automatically.
2778
2899
  *
2779
2900
  * ```js
2780
- * import { openSync, closeSync, appendFileSync } from 'fs';
2901
+ * import { openSync, closeSync, appendFileSync } from 'node:fs';
2781
2902
  *
2782
2903
  * let fd;
2783
2904
  *
@@ -2859,7 +2980,7 @@ declare module 'fs' {
2859
2980
  * stat object:
2860
2981
  *
2861
2982
  * ```js
2862
- * import { watchFile } from 'fs';
2983
+ * import { watchFile } from 'node:fs';
2863
2984
  *
2864
2985
  * watchFile('message.text', (curr, prev) => {
2865
2986
  * console.log(`the current mtime is: ${curr.mtime}`);
@@ -2992,7 +3113,7 @@ declare module 'fs' {
2992
3113
  * Then call the `callback` argument with either true or false:
2993
3114
  *
2994
3115
  * ```js
2995
- * import { exists } from 'fs';
3116
+ * import { exists } from 'node:fs';
2996
3117
  *
2997
3118
  * exists('/etc/passwd', (e) => {
2998
3119
  * console.log(e ? 'it exists' : 'no passwd!');
@@ -3004,7 +3125,7 @@ declare module 'fs' {
3004
3125
  * has only one boolean parameter. This is one reason `fs.access()` is recommended
3005
3126
  * instead of `fs.exists()`.
3006
3127
  *
3007
- * Using `fs.exists()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended. Doing
3128
+ * Using `fs.exists()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended. Doing
3008
3129
  * so introduces a race condition, since other processes may change the file's
3009
3130
  * state between the two calls. Instead, user code should open/read/write the
3010
3131
  * file directly and handle the error raised if the file does not exist.
@@ -3012,7 +3133,7 @@ declare module 'fs' {
3012
3133
  * **write (NOT RECOMMENDED)**
3013
3134
  *
3014
3135
  * ```js
3015
- * import { exists, open, close } from 'fs';
3136
+ * import { exists, open, close } from 'node:fs';
3016
3137
  *
3017
3138
  * exists('myfile', (e) => {
3018
3139
  * if (e) {
@@ -3036,7 +3157,7 @@ declare module 'fs' {
3036
3157
  * **write (RECOMMENDED)**
3037
3158
  *
3038
3159
  * ```js
3039
- * import { open, close } from 'fs';
3160
+ * import { open, close } from 'node:fs';
3040
3161
  * open('myfile', 'wx', (err, fd) => {
3041
3162
  * if (err) {
3042
3163
  * if (err.code === 'EEXIST') {
@@ -3060,7 +3181,7 @@ declare module 'fs' {
3060
3181
  * **read (NOT RECOMMENDED)**
3061
3182
  *
3062
3183
  * ```js
3063
- * import { open, close, exists } from 'fs';
3184
+ * import { open, close, exists } from 'node:fs';
3064
3185
  *
3065
3186
  * exists('myfile', (e) => {
3066
3187
  * if (e) {
@@ -3084,7 +3205,7 @@ declare module 'fs' {
3084
3205
  * **read (RECOMMENDED)**
3085
3206
  *
3086
3207
  * ```js
3087
- * import { open, close } from 'fs';
3208
+ * import { open, close } from 'node:fs';
3088
3209
  *
3089
3210
  * open('myfile', 'r', (err, fd) => {
3090
3211
  * if (err) {
@@ -3110,7 +3231,7 @@ declare module 'fs' {
3110
3231
  * file; the "recommended" examples are better because they use the file directly
3111
3232
  * and handle the error, if any.
3112
3233
  *
3113
- * In general, check for the existence of a file only if the file wont be
3234
+ * In general, check for the existence of a file only if the file won't be
3114
3235
  * used directly, for example when its existence is a signal from another
3115
3236
  * process.
3116
3237
  * @since v0.0.2
@@ -3135,7 +3256,7 @@ declare module 'fs' {
3135
3256
  * Node.js callbacks. `fs.existsSync()` does not use a callback.
3136
3257
  *
3137
3258
  * ```js
3138
- * import { existsSync } from 'fs';
3259
+ * import { existsSync } from 'node:fs';
3139
3260
  *
3140
3261
  * if (existsSync('/etc/passwd'))
3141
3262
  * console.log('The path exists.');
@@ -3269,7 +3390,7 @@ declare module 'fs' {
3269
3390
  * argument will be an `Error` object. The following examples check if`package.json` exists, and if it is readable or writable.
3270
3391
  *
3271
3392
  * ```js
3272
- * import { access, constants } from 'fs';
3393
+ * import { access, constants } from 'node:fs';
3273
3394
  *
3274
3395
  * const file = 'package.json';
3275
3396
  *
@@ -3294,7 +3415,7 @@ declare module 'fs' {
3294
3415
  * });
3295
3416
  * ```
3296
3417
  *
3297
- * Do not use `fs.access()` to check for the accessibility of a file before calling`fs.open()`, `fs.readFile()` or `fs.writeFile()`. Doing
3418
+ * Do not use `fs.access()` to check for the accessibility of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()`. Doing
3298
3419
  * so introduces a race condition, since other processes may change the file's
3299
3420
  * state between the two calls. Instead, user code should open/read/write the
3300
3421
  * file directly and handle the error raised if the file is not accessible.
@@ -3302,7 +3423,7 @@ declare module 'fs' {
3302
3423
  * **write (NOT RECOMMENDED)**
3303
3424
  *
3304
3425
  * ```js
3305
- * import { access, open, close } from 'fs';
3426
+ * import { access, open, close } from 'node:fs';
3306
3427
  *
3307
3428
  * access('myfile', (err) => {
3308
3429
  * if (!err) {
@@ -3327,7 +3448,7 @@ declare module 'fs' {
3327
3448
  * **write (RECOMMENDED)**
3328
3449
  *
3329
3450
  * ```js
3330
- * import { open, close } from 'fs';
3451
+ * import { open, close } from 'node:fs';
3331
3452
  *
3332
3453
  * open('myfile', 'wx', (err, fd) => {
3333
3454
  * if (err) {
@@ -3352,7 +3473,7 @@ declare module 'fs' {
3352
3473
  * **read (NOT RECOMMENDED)**
3353
3474
  *
3354
3475
  * ```js
3355
- * import { access, open, close } from 'fs';
3476
+ * import { access, open, close } from 'node:fs';
3356
3477
  * access('myfile', (err) => {
3357
3478
  * if (err) {
3358
3479
  * if (err.code === 'ENOENT') {
@@ -3380,7 +3501,7 @@ declare module 'fs' {
3380
3501
  * **read (RECOMMENDED)**
3381
3502
  *
3382
3503
  * ```js
3383
- * import { open, close } from 'fs';
3504
+ * import { open, close } from 'node:fs';
3384
3505
  *
3385
3506
  * open('myfile', 'r', (err, fd) => {
3386
3507
  * if (err) {
@@ -3442,7 +3563,7 @@ declare module 'fs' {
3442
3563
  * the method will return `undefined`.
3443
3564
  *
3444
3565
  * ```js
3445
- * import { accessSync, constants } from 'fs';
3566
+ * import { accessSync, constants } from 'node:fs';
3446
3567
  *
3447
3568
  * try {
3448
3569
  * accessSync('etc/passwd', constants.R_OK | constants.W_OK);
@@ -3472,8 +3593,8 @@ declare module 'fs' {
3472
3593
  end?: number | undefined;
3473
3594
  }
3474
3595
  /**
3475
- * Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream
3476
- * returned by this method has a default `highWaterMark` of 64 kb.
3596
+ * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream
3597
+ * returned by this method has a default `highWaterMark` of 64 KiB.
3477
3598
  *
3478
3599
  * `options` can include `start` and `end` values to read a range of bytes from
3479
3600
  * the file instead of the entire file. Both `start` and `end` are inclusive and
@@ -3499,7 +3620,7 @@ declare module 'fs' {
3499
3620
  * also required.
3500
3621
  *
3501
3622
  * ```js
3502
- * import { createReadStream } from 'fs';
3623
+ * import { createReadStream } from 'node:fs';
3503
3624
  *
3504
3625
  * // Create a stream from some character device.
3505
3626
  * const stream = createReadStream('/dev/input/event0');
@@ -3527,7 +3648,7 @@ declare module 'fs' {
3527
3648
  * An example to read the last 10 bytes of a file which is 100 bytes long:
3528
3649
  *
3529
3650
  * ```js
3530
- * import { createReadStream } from 'fs';
3651
+ * import { createReadStream } from 'node:fs';
3531
3652
  *
3532
3653
  * createReadStream('sample.txt', { start: 90, end: 99 });
3533
3654
  * ```
@@ -3551,7 +3672,7 @@ declare module 'fs' {
3551
3672
  * By default, the stream will emit a `'close'` event after it has been
3552
3673
  * destroyed. Set the `emitClose` option to `false` to change this behavior.
3553
3674
  *
3554
- * By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev` and `close`. Overriding `write()`without `writev()` can reduce
3675
+ * By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev`, and `close`. Overriding `write()`without `writev()` can reduce
3555
3676
  * performance as some optimizations (`_writev()`)
3556
3677
  * will be disabled. When providing the `fs` option, overrides for at least one of`write` and `writev` are required. If no `fd` option is supplied, an override
3557
3678
  * for `open` is also required. If `autoClose` is `true`, an override for `close`is also required.
@@ -3606,7 +3727,7 @@ declare module 'fs' {
3606
3727
  * copy-on-write, then the operation will fail.
3607
3728
  *
3608
3729
  * ```js
3609
- * import { copyFile, constants } from 'fs';
3730
+ * import { copyFile, constants } from 'node:fs';
3610
3731
  *
3611
3732
  * function callback(err) {
3612
3733
  * if (err) throw err;
@@ -3649,7 +3770,7 @@ declare module 'fs' {
3649
3770
  * copy-on-write, then the operation will fail.
3650
3771
  *
3651
3772
  * ```js
3652
- * import { copyFileSync, constants } from 'fs';
3773
+ * import { copyFileSync, constants } from 'node:fs';
3653
3774
  *
3654
3775
  * // destination.txt will be created or overwritten by default.
3655
3776
  * copyFileSync('source.txt', 'destination.txt');
@@ -3682,6 +3803,7 @@ declare module 'fs' {
3682
3803
  * The kernel ignores the position argument and always appends the data to
3683
3804
  * the end of the file.
3684
3805
  * @since v12.9.0
3806
+ * @param [position='null']
3685
3807
  */
3686
3808
  export function writev(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
3687
3809
  export function writev(
@@ -3701,6 +3823,7 @@ declare module 'fs' {
3701
3823
  * For detailed information, see the documentation of the asynchronous version of
3702
3824
  * this API: {@link writev}.
3703
3825
  * @since v12.9.0
3826
+ * @param [position='null']
3704
3827
  * @return The number of bytes written.
3705
3828
  */
3706
3829
  export function writevSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
@@ -3717,6 +3840,7 @@ declare module 'fs' {
3717
3840
  * If this method is invoked as its `util.promisify()` ed version, it returns
3718
3841
  * a promise for an `Object` with `bytesRead` and `buffers` properties.
3719
3842
  * @since v13.13.0, v12.17.0
3843
+ * @param [position='null']
3720
3844
  */
3721
3845
  export function readv(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
3722
3846
  export function readv(
@@ -3736,10 +3860,14 @@ declare module 'fs' {
3736
3860
  * For detailed information, see the documentation of the asynchronous version of
3737
3861
  * this API: {@link readv}.
3738
3862
  * @since v13.13.0, v12.17.0
3863
+ * @param [position='null']
3739
3864
  * @return The number of bytes read.
3740
3865
  */
3741
3866
  export function readvSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
3742
3867
  export interface OpenDirOptions {
3868
+ /**
3869
+ * @default 'utf8'
3870
+ */
3743
3871
  encoding?: BufferEncoding | undefined;
3744
3872
  /**
3745
3873
  * Number of directory entries that are buffered
@@ -3748,6 +3876,10 @@ declare module 'fs' {
3748
3876
  * @default 32
3749
3877
  */
3750
3878
  bufferSize?: number | undefined;
3879
+ /**
3880
+ * @default false
3881
+ */
3882
+ recursive?: boolean;
3751
3883
  }
3752
3884
  /**
3753
3885
  * Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html).
@@ -3810,6 +3942,10 @@ declare module 'fs' {
3810
3942
  * @default true
3811
3943
  */
3812
3944
  force?: boolean;
3945
+ /**
3946
+ * Modifiers for copy operation. See `mode` flag of {@link copyFileSync()}
3947
+ */
3948
+ mode?: number;
3813
3949
  /**
3814
3950
  * When `true` timestamps from `src` will
3815
3951
  * be preserved.