@types/node 16.0.1 → 16.3.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.
node/fs.d.ts CHANGED
@@ -10,14 +10,20 @@ declare module 'fs' {
10
10
  */
11
11
  export type PathLike = string | Buffer | URL;
12
12
 
13
+ export type PathOrFileDescriptor = PathLike | number;
14
+
15
+ export type TimeLike = string | number | Date;
16
+
13
17
  export type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
14
18
 
15
19
  export type BufferEncodingOption = 'buffer' | { encoding: 'buffer' };
16
20
 
17
- export interface BaseEncodingOptions {
21
+ export interface ObjectEncodingOptions {
18
22
  encoding?: BufferEncoding | null | undefined;
19
23
  }
20
24
 
25
+ export type EncodingOption = ObjectEncodingOptions | BufferEncoding | undefined | null;
26
+
21
27
  export type OpenMode = number | string;
22
28
 
23
29
  export type Mode = number | string;
@@ -71,7 +77,7 @@ declare module 'fs' {
71
77
  /**
72
78
  * A class representing a directory stream.
73
79
  */
74
- export class Dir {
80
+ export class Dir implements AsyncIterable<Dirent> {
75
81
  readonly path: string;
76
82
 
77
83
  /**
@@ -430,7 +436,7 @@ declare module 'fs' {
430
436
  * @param atime The last access time. If a string is provided, it will be coerced to number.
431
437
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
432
438
  */
433
- export function lutimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
439
+ export function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
434
440
 
435
441
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
436
442
  export namespace lutimes {
@@ -442,7 +448,7 @@ declare module 'fs' {
442
448
  * @param atime The last access time. If a string is provided, it will be coerced to number.
443
449
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
444
450
  */
445
- function __promisify__(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
451
+ function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
446
452
  }
447
453
 
448
454
  /**
@@ -453,7 +459,7 @@ declare module 'fs' {
453
459
  * @param atime The last access time. If a string is provided, it will be coerced to number.
454
460
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
455
461
  */
456
- export function lutimesSync(path: PathLike, atime: string | number | Date, mtime: string | number | Date): void;
462
+ export function lutimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;
457
463
 
458
464
  /**
459
465
  * Asynchronous chmod(2) - Change permissions of a file.
@@ -684,7 +690,7 @@ declare module 'fs' {
684
690
  */
685
691
  export function readlink(
686
692
  path: PathLike,
687
- options: BaseEncodingOptions | BufferEncoding | undefined | null,
693
+ options: EncodingOption,
688
694
  callback: (err: NodeJS.ErrnoException | null, linkString: string) => void
689
695
  ): void;
690
696
 
@@ -700,7 +706,7 @@ declare module 'fs' {
700
706
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
701
707
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
702
708
  */
703
- export function readlink(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void): void;
709
+ export function readlink(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void): void;
704
710
 
705
711
  /**
706
712
  * Asynchronous readlink(2) - read value of a symbolic link.
@@ -715,7 +721,7 @@ declare module 'fs' {
715
721
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
716
722
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
717
723
  */
718
- function __promisify__(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>;
724
+ function __promisify__(path: PathLike, options?: EncodingOption): Promise<string>;
719
725
 
720
726
  /**
721
727
  * Asynchronous readlink(2) - read value of a symbolic link.
@@ -729,7 +735,7 @@ declare module 'fs' {
729
735
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
730
736
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
731
737
  */
732
- function __promisify__(path: PathLike, options?: BaseEncodingOptions | string | null): Promise<string | Buffer>;
738
+ function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
733
739
  }
734
740
 
735
741
  /**
@@ -737,7 +743,7 @@ declare module 'fs' {
737
743
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
738
744
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
739
745
  */
740
- export function readlinkSync(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string;
746
+ export function readlinkSync(path: PathLike, options?: EncodingOption): string;
741
747
 
742
748
  /**
743
749
  * Synchronous readlink(2) - read value of a symbolic link.
@@ -751,7 +757,7 @@ declare module 'fs' {
751
757
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
752
758
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
753
759
  */
754
- export function readlinkSync(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer;
760
+ export function readlinkSync(path: PathLike, options?: EncodingOption): string | Buffer;
755
761
 
756
762
  /**
757
763
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
@@ -760,7 +766,7 @@ declare module 'fs' {
760
766
  */
761
767
  export function realpath(
762
768
  path: PathLike,
763
- options: BaseEncodingOptions | BufferEncoding | undefined | null,
769
+ options: EncodingOption,
764
770
  callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void
765
771
  ): void;
766
772
 
@@ -776,7 +782,7 @@ declare module 'fs' {
776
782
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
777
783
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
778
784
  */
779
- export function realpath(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
785
+ export function realpath(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
780
786
 
781
787
  /**
782
788
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
@@ -791,7 +797,7 @@ declare module 'fs' {
791
797
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
792
798
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
793
799
  */
794
- function __promisify__(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>;
800
+ function __promisify__(path: PathLike, options?: EncodingOption): Promise<string>;
795
801
 
796
802
  /**
797
803
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
@@ -805,15 +811,15 @@ declare module 'fs' {
805
811
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
806
812
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
807
813
  */
808
- function __promisify__(path: PathLike, options?: BaseEncodingOptions | string | null): Promise<string | Buffer>;
814
+ function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
809
815
 
810
816
  function native(
811
817
  path: PathLike,
812
- options: BaseEncodingOptions | BufferEncoding | undefined | null,
818
+ options: EncodingOption,
813
819
  callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void
814
820
  ): void;
815
821
  function native(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
816
- function native(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
822
+ function native(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
817
823
  function native(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
818
824
  }
819
825
 
@@ -822,7 +828,7 @@ declare module 'fs' {
822
828
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
823
829
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
824
830
  */
825
- export function realpathSync(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string;
831
+ export function realpathSync(path: PathLike, options?: EncodingOption): string;
826
832
 
827
833
  /**
828
834
  * Synchronous realpath(3) - return the canonicalized absolute pathname.
@@ -836,12 +842,12 @@ declare module 'fs' {
836
842
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
837
843
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
838
844
  */
839
- export function realpathSync(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer;
845
+ export function realpathSync(path: PathLike, options?: EncodingOption): string | Buffer;
840
846
 
841
847
  export namespace realpathSync {
842
- function native(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string;
848
+ function native(path: PathLike, options?: EncodingOption): string;
843
849
  function native(path: PathLike, options: BufferEncodingOption): Buffer;
844
- function native(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer;
850
+ function native(path: PathLike, options?: EncodingOption): string | Buffer;
845
851
  }
846
852
 
847
853
  /**
@@ -875,6 +881,16 @@ declare module 'fs' {
875
881
  * @default 0
876
882
  */
877
883
  maxRetries?: number | undefined;
884
+ /**
885
+ * @deprecated since v14.14.0 In future versions of Node.js and will trigger a warning
886
+ * `fs.rmdir(path, { recursive: true })` will throw if `path` does not exist or is a file.
887
+ * Use `fs.rm(path, { recursive: true, force: true })` instead.
888
+ *
889
+ * If `true`, perform a recursive directory removal. In
890
+ * recursive mode soperations are retried on failure.
891
+ * @default false
892
+ */
893
+ recursive?: boolean | undefined;
878
894
  /**
879
895
  * The amount of time in milliseconds to wait between retries.
880
896
  * This option is ignored if the `recursive` option is not `true`.
@@ -1053,7 +1069,7 @@ declare module 'fs' {
1053
1069
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1054
1070
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1055
1071
  */
1056
- export function mkdtemp(prefix: string, options: BaseEncodingOptions | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
1072
+ export function mkdtemp(prefix: string, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
1057
1073
 
1058
1074
  /**
1059
1075
  * Asynchronously creates a unique temporary directory.
@@ -1067,7 +1083,7 @@ declare module 'fs' {
1067
1083
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1068
1084
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1069
1085
  */
1070
- export function mkdtemp(prefix: string, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void): void;
1086
+ export function mkdtemp(prefix: string, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void): void;
1071
1087
 
1072
1088
  /**
1073
1089
  * Asynchronously creates a unique temporary directory.
@@ -1082,7 +1098,7 @@ declare module 'fs' {
1082
1098
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1083
1099
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1084
1100
  */
1085
- function __promisify__(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>;
1101
+ function __promisify__(prefix: string, options?: EncodingOption): Promise<string>;
1086
1102
 
1087
1103
  /**
1088
1104
  * Asynchronously creates a unique temporary directory.
@@ -1096,7 +1112,7 @@ declare module 'fs' {
1096
1112
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1097
1113
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1098
1114
  */
1099
- function __promisify__(prefix: string, options?: BaseEncodingOptions | string | null): Promise<string | Buffer>;
1115
+ function __promisify__(prefix: string, options?: EncodingOption): Promise<string | Buffer>;
1100
1116
  }
1101
1117
 
1102
1118
  /**
@@ -1104,7 +1120,7 @@ declare module 'fs' {
1104
1120
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1105
1121
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1106
1122
  */
1107
- export function mkdtempSync(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): string;
1123
+ export function mkdtempSync(prefix: string, options?: EncodingOption): string;
1108
1124
 
1109
1125
  /**
1110
1126
  * Synchronously creates a unique temporary directory.
@@ -1118,7 +1134,7 @@ declare module 'fs' {
1118
1134
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1119
1135
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1120
1136
  */
1121
- export function mkdtempSync(prefix: string, options?: BaseEncodingOptions | string | null): string | Buffer;
1137
+ export function mkdtempSync(prefix: string, options?: EncodingOption): string | Buffer;
1122
1138
 
1123
1139
  /**
1124
1140
  * Asynchronous readdir(3) - read a directory.
@@ -1149,7 +1165,7 @@ declare module 'fs' {
1149
1165
  */
1150
1166
  export function readdir(
1151
1167
  path: PathLike,
1152
- options: BaseEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | undefined | null,
1168
+ options: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | undefined | null,
1153
1169
  callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void,
1154
1170
  ): void;
1155
1171
 
@@ -1164,7 +1180,7 @@ declare module 'fs' {
1164
1180
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1165
1181
  * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
1166
1182
  */
1167
- export function readdir(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }, callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void): void;
1183
+ export function readdir(path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true }, callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void): void;
1168
1184
 
1169
1185
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1170
1186
  export namespace readdir {
@@ -1187,14 +1203,14 @@ declare module 'fs' {
1187
1203
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1188
1204
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1189
1205
  */
1190
- function __promisify__(path: PathLike, options?: BaseEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): Promise<string[] | Buffer[]>;
1206
+ function __promisify__(path: PathLike, options?: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): Promise<string[] | Buffer[]>;
1191
1207
 
1192
1208
  /**
1193
1209
  * Asynchronous readdir(3) - read a directory.
1194
1210
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1195
1211
  * @param options If called with `withFileTypes: true` the result data will be an array of Dirent
1196
1212
  */
1197
- function __promisify__(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Promise<Dirent[]>;
1213
+ function __promisify__(path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true }): Promise<Dirent[]>;
1198
1214
  }
1199
1215
 
1200
1216
  /**
@@ -1216,14 +1232,14 @@ declare module 'fs' {
1216
1232
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1217
1233
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1218
1234
  */
1219
- export function readdirSync(path: PathLike, options?: BaseEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): string[] | Buffer[];
1235
+ export function readdirSync(path: PathLike, options?: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): string[] | Buffer[];
1220
1236
 
1221
1237
  /**
1222
1238
  * Synchronous readdir(3) - read a directory.
1223
1239
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1224
1240
  * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
1225
1241
  */
1226
- export function readdirSync(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Dirent[];
1242
+ export function readdirSync(path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true }): Dirent[];
1227
1243
 
1228
1244
  /**
1229
1245
  * Asynchronous close(2) - close a file descriptor.
@@ -1282,7 +1298,7 @@ declare module 'fs' {
1282
1298
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1283
1299
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1284
1300
  */
1285
- export function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
1301
+ export function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
1286
1302
 
1287
1303
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1288
1304
  export namespace utimes {
@@ -1292,7 +1308,7 @@ declare module 'fs' {
1292
1308
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1293
1309
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1294
1310
  */
1295
- function __promisify__(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
1311
+ function __promisify__(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
1296
1312
  }
1297
1313
 
1298
1314
  /**
@@ -1301,7 +1317,7 @@ declare module 'fs' {
1301
1317
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1302
1318
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1303
1319
  */
1304
- export function utimesSync(path: PathLike, atime: string | number | Date, mtime: string | number | Date): void;
1320
+ export function utimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;
1305
1321
 
1306
1322
  /**
1307
1323
  * Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
@@ -1309,7 +1325,7 @@ declare module 'fs' {
1309
1325
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1310
1326
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1311
1327
  */
1312
- export function futimes(fd: number, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
1328
+ export function futimes(fd: number, atime: TimeLike, mtime: TimeLike, callback: NoParamCallback): void;
1313
1329
 
1314
1330
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1315
1331
  export namespace futimes {
@@ -1319,7 +1335,7 @@ declare module 'fs' {
1319
1335
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1320
1336
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1321
1337
  */
1322
- function __promisify__(fd: number, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
1338
+ function __promisify__(fd: number, atime: TimeLike, mtime: TimeLike): Promise<void>;
1323
1339
  }
1324
1340
 
1325
1341
  /**
@@ -1328,7 +1344,7 @@ declare module 'fs' {
1328
1344
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1329
1345
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1330
1346
  */
1331
- export function futimesSync(fd: number, atime: string | number | Date, mtime: string | number | Date): void;
1347
+ export function futimesSync(fd: number, atime: TimeLike, mtime: TimeLike): void;
1332
1348
 
1333
1349
  /**
1334
1350
  * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
@@ -1550,7 +1566,7 @@ declare module 'fs' {
1550
1566
  * If a flag is not provided, it defaults to `'r'`.
1551
1567
  */
1552
1568
  export function readFile(
1553
- path: PathLike | number,
1569
+ path: PathOrFileDescriptor,
1554
1570
  options: { encoding?: null | undefined; flag?: string | undefined; } & Abortable | undefined | null,
1555
1571
  callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void,
1556
1572
  ): void;
@@ -1563,7 +1579,7 @@ declare module 'fs' {
1563
1579
  * If a flag is not provided, it defaults to `'r'`.
1564
1580
  */
1565
1581
  export function readFile(
1566
- path: PathLike | number,
1582
+ path: PathOrFileDescriptor,
1567
1583
  options: { encoding: BufferEncoding; flag?: string | undefined; } & Abortable | string,
1568
1584
  callback: (err: NodeJS.ErrnoException | null, data: string) => void,
1569
1585
  ): void;
@@ -1576,9 +1592,8 @@ declare module 'fs' {
1576
1592
  * If a flag is not provided, it defaults to `'r'`.
1577
1593
  */
1578
1594
  export function readFile(
1579
- path: PathLike | number,
1580
- // TODO: unify the options across all readfile functions
1581
- options: BaseEncodingOptions & { flag?: string | undefined; } & Abortable | string | undefined | null,
1595
+ path: PathOrFileDescriptor,
1596
+ options: ObjectEncodingOptions & { flag?: string | undefined; } & Abortable | string | undefined | null,
1582
1597
  callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void,
1583
1598
  ): void;
1584
1599
 
@@ -1587,7 +1602,7 @@ declare module 'fs' {
1587
1602
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1588
1603
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1589
1604
  */
1590
- export function readFile(path: PathLike | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
1605
+ export function readFile(path: PathOrFileDescriptor, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
1591
1606
 
1592
1607
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1593
1608
  export namespace readFile {
@@ -1598,7 +1613,7 @@ declare module 'fs' {
1598
1613
  * @param options An object that may contain an optional flag.
1599
1614
  * If a flag is not provided, it defaults to `'r'`.
1600
1615
  */
1601
- function __promisify__(path: PathLike | number, options?: { encoding?: null | undefined; flag?: string | undefined; } | null): Promise<Buffer>;
1616
+ function __promisify__(path: PathOrFileDescriptor, options?: { encoding?: null | undefined; flag?: string | undefined; } | null): Promise<Buffer>;
1602
1617
 
1603
1618
  /**
1604
1619
  * Asynchronously reads the entire contents of a file.
@@ -1608,7 +1623,7 @@ declare module 'fs' {
1608
1623
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1609
1624
  * If a flag is not provided, it defaults to `'r'`.
1610
1625
  */
1611
- function __promisify__(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string | undefined; } | string): Promise<string>;
1626
+ function __promisify__(path: PathOrFileDescriptor, options: { encoding: BufferEncoding; flag?: string | undefined; } | string): Promise<string>;
1612
1627
 
1613
1628
  /**
1614
1629
  * Asynchronously reads the entire contents of a file.
@@ -1618,7 +1633,7 @@ declare module 'fs' {
1618
1633
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1619
1634
  * If a flag is not provided, it defaults to `'r'`.
1620
1635
  */
1621
- function __promisify__(path: PathLike | number, options?: BaseEncodingOptions & { flag?: string | undefined; } | string | null): Promise<string | Buffer>;
1636
+ function __promisify__(path: PathOrFileDescriptor, options?: ObjectEncodingOptions & { flag?: string | undefined; } | string | null): Promise<string | Buffer>;
1622
1637
  }
1623
1638
 
1624
1639
  /**
@@ -1627,7 +1642,7 @@ declare module 'fs' {
1627
1642
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1628
1643
  * @param options An object that may contain an optional flag. If a flag is not provided, it defaults to `'r'`.
1629
1644
  */
1630
- export function readFileSync(path: PathLike | number, options?: { encoding?: null | undefined; flag?: string | undefined; } | null): Buffer;
1645
+ export function readFileSync(path: PathOrFileDescriptor, options?: { encoding?: null | undefined; flag?: string | undefined; } | null): Buffer;
1631
1646
 
1632
1647
  /**
1633
1648
  * Synchronously reads the entire contents of a file.
@@ -1636,7 +1651,7 @@ declare module 'fs' {
1636
1651
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1637
1652
  * If a flag is not provided, it defaults to `'r'`.
1638
1653
  */
1639
- export function readFileSync(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string | undefined; } | BufferEncoding): string;
1654
+ export function readFileSync(path: PathOrFileDescriptor, options: { encoding: BufferEncoding; flag?: string | undefined; } | BufferEncoding): string;
1640
1655
 
1641
1656
  /**
1642
1657
  * Synchronously reads the entire contents of a file.
@@ -1645,9 +1660,9 @@ declare module 'fs' {
1645
1660
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1646
1661
  * If a flag is not provided, it defaults to `'r'`.
1647
1662
  */
1648
- export function readFileSync(path: PathLike | number, options?: BaseEncodingOptions & { flag?: string | undefined; } | BufferEncoding | null): string | Buffer;
1663
+ export function readFileSync(path: PathOrFileDescriptor, options?: ObjectEncodingOptions & { flag?: string | undefined; } | BufferEncoding | null): string | Buffer;
1649
1664
 
1650
- export type WriteFileOptions = (BaseEncodingOptions & Abortable & { mode?: Mode | undefined; flag?: string | undefined; }) | string | null;
1665
+ export type WriteFileOptions = (ObjectEncodingOptions & Abortable & { mode?: Mode | undefined; flag?: string | undefined; }) | string | null;
1651
1666
 
1652
1667
  /**
1653
1668
  * Asynchronously writes data to a file, replacing the file if it already exists.
@@ -1660,7 +1675,7 @@ declare module 'fs' {
1660
1675
  * If `mode` is a string, it is parsed as an octal integer.
1661
1676
  * If `flag` is not supplied, the default of `'w'` is used.
1662
1677
  */
1663
- export function writeFile(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: NoParamCallback): void;
1678
+ export function writeFile(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: NoParamCallback): void;
1664
1679
 
1665
1680
  /**
1666
1681
  * Asynchronously writes data to a file, replacing the file if it already exists.
@@ -1668,7 +1683,7 @@ declare module 'fs' {
1668
1683
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1669
1684
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1670
1685
  */
1671
- export function writeFile(path: PathLike | number, data: string | NodeJS.ArrayBufferView, callback: NoParamCallback): void;
1686
+ export function writeFile(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, callback: NoParamCallback): void;
1672
1687
 
1673
1688
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1674
1689
  export namespace writeFile {
@@ -1684,7 +1699,7 @@ declare module 'fs' {
1684
1699
  * If `mode` is a string, it is parsed as an octal integer.
1685
1700
  * If `flag` is not supplied, the default of `'w'` is used.
1686
1701
  */
1687
- function __promisify__(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): Promise<void>;
1702
+ function __promisify__(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): Promise<void>;
1688
1703
  }
1689
1704
 
1690
1705
  /**
@@ -1698,7 +1713,7 @@ declare module 'fs' {
1698
1713
  * If `mode` is a string, it is parsed as an octal integer.
1699
1714
  * If `flag` is not supplied, the default of `'w'` is used.
1700
1715
  */
1701
- export function writeFileSync(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void;
1716
+ export function writeFileSync(path: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void;
1702
1717
 
1703
1718
  /**
1704
1719
  * Asynchronously append data to a file, creating the file if it does not exist.
@@ -1711,7 +1726,7 @@ declare module 'fs' {
1711
1726
  * If `mode` is a string, it is parsed as an octal integer.
1712
1727
  * If `flag` is not supplied, the default of `'a'` is used.
1713
1728
  */
1714
- export function appendFile(file: PathLike | number, data: string | Uint8Array, options: WriteFileOptions, callback: NoParamCallback): void;
1729
+ export function appendFile(file: PathOrFileDescriptor, data: string | Uint8Array, options: WriteFileOptions, callback: NoParamCallback): void;
1715
1730
 
1716
1731
  /**
1717
1732
  * Asynchronously append data to a file, creating the file if it does not exist.
@@ -1719,7 +1734,7 @@ declare module 'fs' {
1719
1734
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1720
1735
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1721
1736
  */
1722
- export function appendFile(file: PathLike | number, data: string | Uint8Array, callback: NoParamCallback): void;
1737
+ export function appendFile(file: PathOrFileDescriptor, data: string | Uint8Array, callback: NoParamCallback): void;
1723
1738
 
1724
1739
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1725
1740
  export namespace appendFile {
@@ -1735,7 +1750,7 @@ declare module 'fs' {
1735
1750
  * If `mode` is a string, it is parsed as an octal integer.
1736
1751
  * If `flag` is not supplied, the default of `'a'` is used.
1737
1752
  */
1738
- function __promisify__(file: PathLike | number, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>;
1753
+ function __promisify__(file: PathOrFileDescriptor, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>;
1739
1754
  }
1740
1755
 
1741
1756
  /**
@@ -1749,7 +1764,7 @@ declare module 'fs' {
1749
1764
  * If `mode` is a string, it is parsed as an octal integer.
1750
1765
  * If `flag` is not supplied, the default of `'a'` is used.
1751
1766
  */
1752
- export function appendFileSync(file: PathLike | number, data: string | Uint8Array, options?: WriteFileOptions): void;
1767
+ export function appendFileSync(file: PathOrFileDescriptor, data: string | Uint8Array, options?: WriteFileOptions): void;
1753
1768
 
1754
1769
  /**
1755
1770
  * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
node/http.d.ts CHANGED
@@ -429,13 +429,6 @@ declare module 'http' {
429
429
  * Defaults to 16KB. Configurable using the `--max-http-header-size` CLI option.
430
430
  */
431
431
  const maxHeaderSize: number;
432
-
433
- /**
434
- *
435
- * This utility function converts a URL object into an ordinary options object as
436
- * expected by the `http.request()` and `https.request()` APIs.
437
- */
438
- function urlToHttpOptions(url: URL): ClientRequestArgs;
439
432
  }
440
433
 
441
434
  declare module 'node:http' {
node/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for non-npm package Node.js 16.0
1
+ // Type definitions for non-npm package Node.js 16.3
2
2
  // Project: http://nodejs.org/
3
3
  // Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
4
4
  // DefinitelyTyped <https://github.com/DefinitelyTyped>
node/os.d.ts CHANGED
@@ -208,6 +208,9 @@ declare module 'os' {
208
208
  }
209
209
  }
210
210
 
211
+ const devNull: string;
212
+ const EOL: string;
213
+
211
214
  function arch(): string;
212
215
  /**
213
216
  * Returns a string identifying the kernel version.
@@ -219,7 +222,6 @@ declare module 'os' {
219
222
  function version(): string;
220
223
  function platform(): NodeJS.Platform;
221
224
  function tmpdir(): string;
222
- const EOL: string;
223
225
  function endianness(): "BE" | "LE";
224
226
  /**
225
227
  * Gets the priority of a process.
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "16.0.1",
3
+ "version": "16.3.1",
4
4
  "description": "TypeScript definitions for Node.js",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -227,6 +227,6 @@
227
227
  },
228
228
  "scripts": {},
229
229
  "dependencies": {},
230
- "typesPublisherContentHash": "439cbcc286cf9e49d4bb3d391b53e338b23d39ce5de6ced5355197c306990b02",
230
+ "typesPublisherContentHash": "888baec56c957c871347e282ffcc5182dd263a4b2e117642a3e22c3dc4111e1f",
231
231
  "typeScriptVersion": "3.6"
232
232
  }