@types/node 16.0.3 → 16.3.3

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
@@ -1,8 +1,8 @@
1
1
  declare module 'fs' {
2
- import * as stream from 'stream';
3
- import { Abortable, EventEmitter } from 'events';
4
- import { URL } from 'url';
5
- import * as promises from 'fs/promises';
2
+ import * as stream from 'node:stream';
3
+ import { Abortable, EventEmitter } from 'node:events';
4
+ import { URL } from 'node:url';
5
+ import * as promises from 'node:fs/promises';
6
6
 
7
7
  export { promises };
8
8
  /**
@@ -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
  /**
@@ -1063,7 +1069,7 @@ declare module 'fs' {
1063
1069
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1064
1070
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1065
1071
  */
1066
- 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;
1067
1073
 
1068
1074
  /**
1069
1075
  * Asynchronously creates a unique temporary directory.
@@ -1077,7 +1083,7 @@ declare module 'fs' {
1077
1083
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1078
1084
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1079
1085
  */
1080
- 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;
1081
1087
 
1082
1088
  /**
1083
1089
  * Asynchronously creates a unique temporary directory.
@@ -1092,7 +1098,7 @@ declare module 'fs' {
1092
1098
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1093
1099
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1094
1100
  */
1095
- function __promisify__(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>;
1101
+ function __promisify__(prefix: string, options?: EncodingOption): Promise<string>;
1096
1102
 
1097
1103
  /**
1098
1104
  * Asynchronously creates a unique temporary directory.
@@ -1106,7 +1112,7 @@ declare module 'fs' {
1106
1112
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1107
1113
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1108
1114
  */
1109
- function __promisify__(prefix: string, options?: BaseEncodingOptions | string | null): Promise<string | Buffer>;
1115
+ function __promisify__(prefix: string, options?: EncodingOption): Promise<string | Buffer>;
1110
1116
  }
1111
1117
 
1112
1118
  /**
@@ -1114,7 +1120,7 @@ declare module 'fs' {
1114
1120
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1115
1121
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1116
1122
  */
1117
- export function mkdtempSync(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): string;
1123
+ export function mkdtempSync(prefix: string, options?: EncodingOption): string;
1118
1124
 
1119
1125
  /**
1120
1126
  * Synchronously creates a unique temporary directory.
@@ -1128,7 +1134,7 @@ declare module 'fs' {
1128
1134
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1129
1135
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1130
1136
  */
1131
- export function mkdtempSync(prefix: string, options?: BaseEncodingOptions | string | null): string | Buffer;
1137
+ export function mkdtempSync(prefix: string, options?: EncodingOption): string | Buffer;
1132
1138
 
1133
1139
  /**
1134
1140
  * Asynchronous readdir(3) - read a directory.
@@ -1159,7 +1165,7 @@ declare module 'fs' {
1159
1165
  */
1160
1166
  export function readdir(
1161
1167
  path: PathLike,
1162
- options: BaseEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | undefined | null,
1168
+ options: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | undefined | null,
1163
1169
  callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void,
1164
1170
  ): void;
1165
1171
 
@@ -1174,7 +1180,7 @@ declare module 'fs' {
1174
1180
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1175
1181
  * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
1176
1182
  */
1177
- 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;
1178
1184
 
1179
1185
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1180
1186
  export namespace readdir {
@@ -1197,14 +1203,14 @@ declare module 'fs' {
1197
1203
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1198
1204
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1199
1205
  */
1200
- 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[]>;
1201
1207
 
1202
1208
  /**
1203
1209
  * Asynchronous readdir(3) - read a directory.
1204
1210
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1205
1211
  * @param options If called with `withFileTypes: true` the result data will be an array of Dirent
1206
1212
  */
1207
- function __promisify__(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Promise<Dirent[]>;
1213
+ function __promisify__(path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true }): Promise<Dirent[]>;
1208
1214
  }
1209
1215
 
1210
1216
  /**
@@ -1226,14 +1232,14 @@ declare module 'fs' {
1226
1232
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1227
1233
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1228
1234
  */
1229
- 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[];
1230
1236
 
1231
1237
  /**
1232
1238
  * Synchronous readdir(3) - read a directory.
1233
1239
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1234
1240
  * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
1235
1241
  */
1236
- export function readdirSync(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Dirent[];
1242
+ export function readdirSync(path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true }): Dirent[];
1237
1243
 
1238
1244
  /**
1239
1245
  * Asynchronous close(2) - close a file descriptor.
@@ -1292,7 +1298,7 @@ declare module 'fs' {
1292
1298
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1293
1299
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1294
1300
  */
1295
- 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;
1296
1302
 
1297
1303
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1298
1304
  export namespace utimes {
@@ -1302,7 +1308,7 @@ declare module 'fs' {
1302
1308
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1303
1309
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1304
1310
  */
1305
- 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>;
1306
1312
  }
1307
1313
 
1308
1314
  /**
@@ -1311,7 +1317,7 @@ declare module 'fs' {
1311
1317
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1312
1318
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1313
1319
  */
1314
- 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;
1315
1321
 
1316
1322
  /**
1317
1323
  * Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
@@ -1319,7 +1325,7 @@ declare module 'fs' {
1319
1325
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1320
1326
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1321
1327
  */
1322
- 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;
1323
1329
 
1324
1330
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1325
1331
  export namespace futimes {
@@ -1329,7 +1335,7 @@ declare module 'fs' {
1329
1335
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1330
1336
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1331
1337
  */
1332
- 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>;
1333
1339
  }
1334
1340
 
1335
1341
  /**
@@ -1338,7 +1344,7 @@ declare module 'fs' {
1338
1344
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1339
1345
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1340
1346
  */
1341
- 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;
1342
1348
 
1343
1349
  /**
1344
1350
  * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
@@ -1560,7 +1566,7 @@ declare module 'fs' {
1560
1566
  * If a flag is not provided, it defaults to `'r'`.
1561
1567
  */
1562
1568
  export function readFile(
1563
- path: PathLike | number,
1569
+ path: PathOrFileDescriptor,
1564
1570
  options: { encoding?: null | undefined; flag?: string | undefined; } & Abortable | undefined | null,
1565
1571
  callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void,
1566
1572
  ): void;
@@ -1573,7 +1579,7 @@ declare module 'fs' {
1573
1579
  * If a flag is not provided, it defaults to `'r'`.
1574
1580
  */
1575
1581
  export function readFile(
1576
- path: PathLike | number,
1582
+ path: PathOrFileDescriptor,
1577
1583
  options: { encoding: BufferEncoding; flag?: string | undefined; } & Abortable | string,
1578
1584
  callback: (err: NodeJS.ErrnoException | null, data: string) => void,
1579
1585
  ): void;
@@ -1586,9 +1592,8 @@ declare module 'fs' {
1586
1592
  * If a flag is not provided, it defaults to `'r'`.
1587
1593
  */
1588
1594
  export function readFile(
1589
- path: PathLike | number,
1590
- // TODO: unify the options across all readfile functions
1591
- options: BaseEncodingOptions & { flag?: string | undefined; } & Abortable | string | undefined | null,
1595
+ path: PathOrFileDescriptor,
1596
+ options: ObjectEncodingOptions & { flag?: string | undefined; } & Abortable | string | undefined | null,
1592
1597
  callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void,
1593
1598
  ): void;
1594
1599
 
@@ -1597,7 +1602,7 @@ declare module 'fs' {
1597
1602
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1598
1603
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1599
1604
  */
1600
- 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;
1601
1606
 
1602
1607
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1603
1608
  export namespace readFile {
@@ -1608,7 +1613,7 @@ declare module 'fs' {
1608
1613
  * @param options An object that may contain an optional flag.
1609
1614
  * If a flag is not provided, it defaults to `'r'`.
1610
1615
  */
1611
- 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>;
1612
1617
 
1613
1618
  /**
1614
1619
  * Asynchronously reads the entire contents of a file.
@@ -1618,7 +1623,7 @@ declare module 'fs' {
1618
1623
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1619
1624
  * If a flag is not provided, it defaults to `'r'`.
1620
1625
  */
1621
- 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>;
1622
1627
 
1623
1628
  /**
1624
1629
  * Asynchronously reads the entire contents of a file.
@@ -1628,7 +1633,7 @@ declare module 'fs' {
1628
1633
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1629
1634
  * If a flag is not provided, it defaults to `'r'`.
1630
1635
  */
1631
- 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>;
1632
1637
  }
1633
1638
 
1634
1639
  /**
@@ -1637,7 +1642,7 @@ declare module 'fs' {
1637
1642
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1638
1643
  * @param options An object that may contain an optional flag. If a flag is not provided, it defaults to `'r'`.
1639
1644
  */
1640
- 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;
1641
1646
 
1642
1647
  /**
1643
1648
  * Synchronously reads the entire contents of a file.
@@ -1646,7 +1651,7 @@ declare module 'fs' {
1646
1651
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1647
1652
  * If a flag is not provided, it defaults to `'r'`.
1648
1653
  */
1649
- 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;
1650
1655
 
1651
1656
  /**
1652
1657
  * Synchronously reads the entire contents of a file.
@@ -1655,9 +1660,9 @@ declare module 'fs' {
1655
1660
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1656
1661
  * If a flag is not provided, it defaults to `'r'`.
1657
1662
  */
1658
- 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;
1659
1664
 
1660
- 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;
1661
1666
 
1662
1667
  /**
1663
1668
  * Asynchronously writes data to a file, replacing the file if it already exists.
@@ -1670,7 +1675,7 @@ declare module 'fs' {
1670
1675
  * If `mode` is a string, it is parsed as an octal integer.
1671
1676
  * If `flag` is not supplied, the default of `'w'` is used.
1672
1677
  */
1673
- 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;
1674
1679
 
1675
1680
  /**
1676
1681
  * Asynchronously writes data to a file, replacing the file if it already exists.
@@ -1678,7 +1683,7 @@ declare module 'fs' {
1678
1683
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1679
1684
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1680
1685
  */
1681
- 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;
1682
1687
 
1683
1688
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1684
1689
  export namespace writeFile {
@@ -1694,7 +1699,7 @@ declare module 'fs' {
1694
1699
  * If `mode` is a string, it is parsed as an octal integer.
1695
1700
  * If `flag` is not supplied, the default of `'w'` is used.
1696
1701
  */
1697
- 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>;
1698
1703
  }
1699
1704
 
1700
1705
  /**
@@ -1708,7 +1713,7 @@ declare module 'fs' {
1708
1713
  * If `mode` is a string, it is parsed as an octal integer.
1709
1714
  * If `flag` is not supplied, the default of `'w'` is used.
1710
1715
  */
1711
- 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;
1712
1717
 
1713
1718
  /**
1714
1719
  * Asynchronously append data to a file, creating the file if it does not exist.
@@ -1721,7 +1726,7 @@ declare module 'fs' {
1721
1726
  * If `mode` is a string, it is parsed as an octal integer.
1722
1727
  * If `flag` is not supplied, the default of `'a'` is used.
1723
1728
  */
1724
- 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;
1725
1730
 
1726
1731
  /**
1727
1732
  * Asynchronously append data to a file, creating the file if it does not exist.
@@ -1729,7 +1734,7 @@ declare module 'fs' {
1729
1734
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1730
1735
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1731
1736
  */
1732
- export function appendFile(file: PathLike | number, data: string | Uint8Array, callback: NoParamCallback): void;
1737
+ export function appendFile(file: PathOrFileDescriptor, data: string | Uint8Array, callback: NoParamCallback): void;
1733
1738
 
1734
1739
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1735
1740
  export namespace appendFile {
@@ -1745,7 +1750,7 @@ declare module 'fs' {
1745
1750
  * If `mode` is a string, it is parsed as an octal integer.
1746
1751
  * If `flag` is not supplied, the default of `'a'` is used.
1747
1752
  */
1748
- function __promisify__(file: PathLike | number, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>;
1753
+ function __promisify__(file: PathOrFileDescriptor, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>;
1749
1754
  }
1750
1755
 
1751
1756
  /**
@@ -1759,7 +1764,7 @@ declare module 'fs' {
1759
1764
  * If `mode` is a string, it is parsed as an octal integer.
1760
1765
  * If `flag` is not supplied, the default of `'a'` is used.
1761
1766
  */
1762
- export function appendFileSync(file: PathLike | number, data: string | Uint8Array, options?: WriteFileOptions): void;
1767
+ export function appendFileSync(file: PathOrFileDescriptor, data: string | Uint8Array, options?: WriteFileOptions): void;
1763
1768
 
1764
1769
  /**
1765
1770
  * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
node/http.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  declare module 'http' {
2
- import * as stream from 'stream';
3
- import { URL } from 'url';
4
- import { Socket, Server as NetServer } from 'net';
2
+ import * as stream from 'node:stream';
3
+ import { URL } from 'node:url';
4
+ import { Socket, Server as NetServer } from 'node:net';
5
5
 
6
6
  // incoming headers will never contain number
7
7
  interface IncomingHttpHeaders extends NodeJS.Dict<string | string[]> {
node/http2.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  declare module 'http2' {
2
- import EventEmitter = require('events');
3
- import * as fs from 'fs';
4
- import * as net from 'net';
5
- import * as stream from 'stream';
6
- import * as tls from 'tls';
7
- import * as url from 'url';
2
+ import EventEmitter = require('node:events');
3
+ import * as fs from 'node:fs';
4
+ import * as net from 'node:net';
5
+ import * as stream from 'node:stream';
6
+ import * as tls from 'node:tls';
7
+ import * as url from 'node:url';
8
8
 
9
9
  import {
10
10
  IncomingHttpHeaders as Http1IncomingHttpHeaders,
11
11
  OutgoingHttpHeaders,
12
12
  IncomingMessage,
13
13
  ServerResponse,
14
- } from 'http';
15
- export { OutgoingHttpHeaders } from 'http';
14
+ } from 'node:http';
15
+ export { OutgoingHttpHeaders } from 'node:http';
16
16
 
17
17
  export interface IncomingHttpStatusHeader {
18
18
  ":status"?: number | undefined;
node/https.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  declare module 'https' {
2
- import * as tls from 'tls';
3
- import * as http from 'http';
4
- import { URL } from 'url';
2
+ import * as tls from 'node:tls';
3
+ import * as http from 'node:http';
4
+ import { URL } from 'node:url';
5
5
 
6
6
  type ServerOptions = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions;
7
7
 
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>