@types/node 16.0.3 → 16.3.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.
node/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (http://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Fri, 09 Jul 2021 00:06:51 GMT
11
+ * Last updated: Fri, 09 Jul 2021 02:01:16 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`
14
14
 
node/async_hooks.d.ts CHANGED
@@ -198,8 +198,7 @@ declare module 'async_hooks' {
198
198
  * I the callback function throws an error, it will be thrown by `run` too. The
199
199
  * stacktrace will not be impacted by this call and the context will be exited.
200
200
  */
201
- // TODO: Apply generic vararg once available
202
- run<R>(store: T, callback: (...args: any[]) => R, ...args: any[]): R;
201
+ run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
203
202
 
204
203
  /**
205
204
  * This methods runs a function synchronously outside of a context and return its
@@ -213,8 +212,7 @@ declare module 'async_hooks' {
213
212
  * stacktrace will not be impacted by this call and the context will be
214
213
  * re-entered.
215
214
  */
216
- // TODO: Apply generic vararg once available
217
- exit<R>(callback: (...args: any[]) => R, ...args: any[]): R;
215
+ exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
218
216
 
219
217
  /**
220
218
  * Calling `asyncLocalStorage.enterWith(store)` will transition into the context
node/child_process.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare module 'child_process' {
2
- import { BaseEncodingOptions } from 'fs';
2
+ import { ObjectEncodingOptions } from 'fs';
3
3
  import { EventEmitter, Abortable } from 'events';
4
4
  import * as net from 'net';
5
5
  import { Writable, Readable, Stream, Pipe } from 'stream';
@@ -327,7 +327,7 @@ declare module 'child_process' {
327
327
  // fallback if nothing else matches. Worst case is always `string | Buffer`.
328
328
  function exec(
329
329
  command: string,
330
- options: (BaseEncodingOptions & ExecOptions) | undefined | null,
330
+ options: (ObjectEncodingOptions & ExecOptions) | undefined | null,
331
331
  callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
332
332
  ): ChildProcess;
333
333
 
@@ -341,7 +341,7 @@ declare module 'child_process' {
341
341
  function __promisify__(command: string, options: { encoding: "buffer" | null } & ExecOptions): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
342
342
  function __promisify__(command: string, options: { encoding: BufferEncoding } & ExecOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
343
343
  function __promisify__(command: string, options: ExecOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
344
- function __promisify__(command: string, options?: (BaseEncodingOptions & ExecOptions) | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
344
+ function __promisify__(command: string, options?: (ObjectEncodingOptions & ExecOptions) | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
345
345
  }
346
346
 
347
347
  interface ExecFileOptions extends CommonOptions, Abortable {
@@ -363,9 +363,9 @@ declare module 'child_process' {
363
363
  type ExecFileException = ExecException & NodeJS.ErrnoException;
364
364
 
365
365
  function execFile(file: string): ChildProcess;
366
- function execFile(file: string, options: (BaseEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
366
+ function execFile(file: string, options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
367
367
  function execFile(file: string, args?: ReadonlyArray<string> | null): ChildProcess;
368
- function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: (BaseEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
368
+ function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
369
369
 
370
370
  // no `options` definitely means stdout/stderr are `string`.
371
371
  function execFile(file: string, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
@@ -415,13 +415,13 @@ declare module 'child_process' {
415
415
  // fallback if nothing else matches. Worst case is always `string | Buffer`.
416
416
  function execFile(
417
417
  file: string,
418
- options: (BaseEncodingOptions & ExecFileOptions) | undefined | null,
418
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
419
419
  callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
420
420
  ): ChildProcess;
421
421
  function execFile(
422
422
  file: string,
423
423
  args: ReadonlyArray<string> | undefined | null,
424
- options: (BaseEncodingOptions & ExecFileOptions) | undefined | null,
424
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
425
425
  callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
426
426
  ): ChildProcess;
427
427
 
@@ -441,11 +441,11 @@ declare module 'child_process' {
441
441
  ): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
442
442
  function __promisify__(file: string, options: ExecFileOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
443
443
  function __promisify__(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
444
- function __promisify__(file: string, options: (BaseEncodingOptions & ExecFileOptions) | undefined | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
444
+ function __promisify__(file: string, options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
445
445
  function __promisify__(
446
446
  file: string,
447
447
  args: ReadonlyArray<string> | undefined | null,
448
- options: (BaseEncodingOptions & ExecFileOptions) | undefined | null,
448
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
449
449
  ): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
450
450
  }
451
451
 
node/crypto.d.ts CHANGED
@@ -1363,8 +1363,6 @@ declare module 'crypto' {
1363
1363
 
1364
1364
  function secureHeapUsed(): SecureHeapUsage;
1365
1365
 
1366
- // TODO: X509Certificate
1367
-
1368
1366
  interface RandomUUIDOptions {
1369
1367
  /**
1370
1368
  * By default, to improve performance,
@@ -1586,6 +1584,10 @@ declare module 'crypto' {
1586
1584
  * Checks the primality of the candidate.
1587
1585
  */
1588
1586
  function checkPrimeSync(value: LargeNumberLike, options?: CheckPrimeOptions): boolean;
1587
+
1588
+ namespace webcrypto {
1589
+ class CryptoKey {} // placeholder
1590
+ }
1589
1591
  }
1590
1592
 
1591
1593
  declare module 'node:crypto' {
node/fs/promises.d.ts CHANGED
@@ -14,13 +14,39 @@ declare module 'fs/promises' {
14
14
  Dirent,
15
15
  OpenDirOptions,
16
16
  Dir,
17
- BaseEncodingOptions,
17
+ ObjectEncodingOptions,
18
18
  BufferEncodingOption,
19
19
  OpenMode,
20
20
  Mode,
21
21
  WatchOptions,
22
22
  } from 'fs';
23
23
 
24
+ interface FlagAndOpenMode {
25
+ mode?: Mode | undefined;
26
+ flag?: OpenMode | undefined;
27
+ }
28
+
29
+ interface FileReadResult<T extends ArrayBufferView> {
30
+ bytesRead: number;
31
+ buffer: T;
32
+ }
33
+
34
+ interface FileReadOptions<T extends ArrayBufferView = Buffer> {
35
+ /**
36
+ * @default `Buffer.alloc(0xffff)`
37
+ */
38
+ buffer?: T;
39
+ /**
40
+ * @default 0
41
+ */
42
+ offset?: number | null;
43
+ /**
44
+ * @default `buffer.byteLength`
45
+ */
46
+ length?: number | null;
47
+ position?: number | null;
48
+ }
49
+
24
50
  // TODO: Add `EventEmitter` close
25
51
  interface FileHandle {
26
52
  /**
@@ -38,7 +64,7 @@ declare module 'fs/promises' {
38
64
  * If `mode` is a string, it is parsed as an octal integer.
39
65
  * If `flag` is not supplied, the default of `'a'` is used.
40
66
  */
41
- appendFile(data: string | Uint8Array, options?: BaseEncodingOptions & { mode?: Mode | undefined, flag?: OpenMode | undefined } | BufferEncoding | null): Promise<void>;
67
+ appendFile(data: string | Uint8Array, options?: ObjectEncodingOptions & FlagAndOpenMode | BufferEncoding | null): Promise<void>;
42
68
 
43
69
  /**
44
70
  * Asynchronous fchown(2) - Change ownership of a file.
@@ -69,8 +95,8 @@ declare module 'fs/promises' {
69
95
  * @param length The number of bytes to read.
70
96
  * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
71
97
  */
72
- read<TBuffer extends Uint8Array>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesRead: number, buffer: TBuffer }>;
73
-
98
+ read<T extends ArrayBufferView>(buffer: T, offset?: number | null, length?: number | null, position?: number | null): Promise<FileReadResult<T>>;
99
+ read<T extends ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
74
100
  /**
75
101
  * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
76
102
  * The `FileHandle` must have been opened for reading.
@@ -93,7 +119,7 @@ declare module 'fs/promises' {
93
119
  * @param options An object that may contain an optional flag.
94
120
  * If a flag is not provided, it defaults to `'r'`.
95
121
  */
96
- readFile(options?: BaseEncodingOptions & { flag?: OpenMode | undefined } | BufferEncoding | null): Promise<string | Buffer>;
122
+ readFile(options?: ObjectEncodingOptions & { flag?: OpenMode | undefined } | BufferEncoding | null): Promise<string | Buffer>;
97
123
 
98
124
  /**
99
125
  * Asynchronous fstat(2) - Get file status.
@@ -147,7 +173,7 @@ declare module 'fs/promises' {
147
173
  * If `mode` is a string, it is parsed as an octal integer.
148
174
  * If `flag` is not supplied, the default of `'w'` is used.
149
175
  */
150
- writeFile(data: string | Uint8Array, options?: BaseEncodingOptions & { mode?: Mode | undefined, flag?: OpenMode | undefined } & Abortable | BufferEncoding | null): Promise<void>;
176
+ writeFile(data: string | Uint8Array, options?: ObjectEncodingOptions & FlagAndOpenMode & Abortable | BufferEncoding | null): Promise<void>;
151
177
 
152
178
  /**
153
179
  * See `fs.writev` promisified version.
@@ -249,7 +275,7 @@ declare module 'fs/promises' {
249
275
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
250
276
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
251
277
  */
252
- function readdir(path: PathLike, options?: BaseEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): Promise<string[]>;
278
+ function readdir(path: PathLike, options?: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): Promise<string[]>;
253
279
 
254
280
  /**
255
281
  * Asynchronous readdir(3) - read a directory.
@@ -263,21 +289,21 @@ declare module 'fs/promises' {
263
289
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
264
290
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
265
291
  */
266
- function readdir(path: PathLike, options?: BaseEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): Promise<string[] | Buffer[]>;
292
+ function readdir(path: PathLike, options?: ObjectEncodingOptions & { withFileTypes?: false | undefined } | BufferEncoding | null): Promise<string[] | Buffer[]>;
267
293
 
268
294
  /**
269
295
  * Asynchronous readdir(3) - read a directory.
270
296
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
271
297
  * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
272
298
  */
273
- function readdir(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Promise<Dirent[]>;
299
+ function readdir(path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true }): Promise<Dirent[]>;
274
300
 
275
301
  /**
276
302
  * Asynchronous readlink(2) - read value of a symbolic link.
277
303
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
278
304
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
279
305
  */
280
- function readlink(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>;
306
+ function readlink(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
281
307
 
282
308
  /**
283
309
  * Asynchronous readlink(2) - read value of a symbolic link.
@@ -291,7 +317,7 @@ declare module 'fs/promises' {
291
317
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
292
318
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
293
319
  */
294
- function readlink(path: PathLike, options?: BaseEncodingOptions | string | null): Promise<string | Buffer>;
320
+ function readlink(path: PathLike, options?: ObjectEncodingOptions | string | null): Promise<string | Buffer>;
295
321
 
296
322
  /**
297
323
  * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
@@ -380,7 +406,7 @@ declare module 'fs/promises' {
380
406
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
381
407
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
382
408
  */
383
- function realpath(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>;
409
+ function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
384
410
 
385
411
  /**
386
412
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
@@ -394,14 +420,14 @@ declare module 'fs/promises' {
394
420
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
395
421
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
396
422
  */
397
- function realpath(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
423
+ function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
398
424
 
399
425
  /**
400
426
  * Asynchronously creates a unique temporary directory.
401
427
  * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
402
428
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
403
429
  */
404
- function mkdtemp(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>;
430
+ function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
405
431
 
406
432
  /**
407
433
  * Asynchronously creates a unique temporary directory.
@@ -415,7 +441,7 @@ declare module 'fs/promises' {
415
441
  * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
416
442
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
417
443
  */
418
- function mkdtemp(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
444
+ function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
419
445
 
420
446
  /**
421
447
  * Asynchronously writes data to a file, replacing the file if it already exists.
@@ -433,7 +459,7 @@ declare module 'fs/promises' {
433
459
  function writeFile(
434
460
  path: PathLike | FileHandle,
435
461
  data: string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | Stream,
436
- options?: BaseEncodingOptions & { mode?: Mode | undefined, flag?: OpenMode | undefined } & Abortable | BufferEncoding | null
462
+ options?: ObjectEncodingOptions & { mode?: Mode | undefined, flag?: OpenMode | undefined } & Abortable | BufferEncoding | null
437
463
  ): Promise<void>;
438
464
 
439
465
  /**
@@ -451,7 +477,7 @@ declare module 'fs/promises' {
451
477
  function appendFile(
452
478
  path: PathLike | FileHandle,
453
479
  data: string | Uint8Array,
454
- options?: BaseEncodingOptions & { mode?: Mode | undefined, flag?: OpenMode | undefined } | BufferEncoding | null
480
+ options?: ObjectEncodingOptions & FlagAndOpenMode | BufferEncoding | null,
455
481
  ): Promise<void>;
456
482
 
457
483
  /**
@@ -479,7 +505,7 @@ declare module 'fs/promises' {
479
505
  * @param options An object that may contain an optional flag.
480
506
  * If a flag is not provided, it defaults to `'r'`.
481
507
  */
482
- function readFile(path: PathLike | FileHandle, options?: BaseEncodingOptions & Abortable & { flag?: OpenMode | undefined } | BufferEncoding | null): Promise<string | Buffer>;
508
+ function readFile(path: PathLike | FileHandle, options?: ObjectEncodingOptions & Abortable & { flag?: OpenMode | undefined } | BufferEncoding | null): Promise<string | Buffer>;
483
509
 
484
510
  function opendir(path: string, options?: OpenDirOptions): Promise<Dir>;
485
511
 
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
  /**
@@ -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/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.3",
3
+ "version": "16.3.0",
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": "51d8ad1a9b0bed07493ef55038c7b74d0dc1c4e052495b0180b5f8bf45bae1d0",
230
+ "typesPublisherContentHash": "4bb604c079055370e21bcc5b3653fe8fda304149e219b7fd226fd35a9de639e9",
231
231
  "typeScriptVersion": "3.6"
232
232
  }
node/process.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  declare module 'process' {
2
2
  import * as tty from 'tty';
3
+ import { Worker } from 'worker_threads';
3
4
 
4
5
  global {
5
6
  var process: NodeJS.Process;
@@ -78,22 +79,26 @@ declare module 'process' {
78
79
  type BeforeExitListener = (code: number) => void;
79
80
  type DisconnectListener = () => void;
80
81
  type ExitListener = (code: number) => void;
81
- type RejectionHandledListener = (promise: Promise<any>) => void;
82
+ type RejectionHandledListener = (promise: Promise<unknown>) => void;
82
83
  type UncaughtExceptionListener = (error: Error) => void;
83
- type UnhandledRejectionListener = (reason: {} | null | undefined, promise: Promise<any>) => void;
84
+ type UnhandledRejectionListener = (reason: {} | null | undefined, promise: Promise<unknown>) => void;
84
85
  type WarningListener = (warning: Error) => void;
85
- type MessageListener = (message: any, sendHandle: any) => void;
86
+ type MessageListener = (message: unknown, sendHandle: unknown) => void;
86
87
  type SignalsListener = (signal: Signals) => void;
87
- type NewListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
88
- type RemoveListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
89
- type MultipleResolveListener = (type: MultipleResolveType, promise: Promise<any>, value: any) => void;
88
+ type MultipleResolveListener = (type: MultipleResolveType, promise: Promise<unknown>, value: unknown) => void;
89
+ type WorkerListener = (worker: Worker) => void;
90
90
 
91
91
  interface Socket extends ReadWriteStream {
92
92
  isTTY?: true | undefined;
93
93
  }
94
94
 
95
95
  // Alias for compatibility
96
- interface ProcessEnv extends Dict<string> {}
96
+ interface ProcessEnv extends Dict<string> {
97
+ /**
98
+ * Can be used to change the default timezone at runtime
99
+ */
100
+ TZ?: string;
101
+ }
97
102
 
98
103
  interface HRTime {
99
104
  (time?: [number, number]): [number, number];
@@ -363,23 +368,21 @@ declare module 'process' {
363
368
  addListener(event: "warning", listener: WarningListener): this;
364
369
  addListener(event: "message", listener: MessageListener): this;
365
370
  addListener(event: Signals, listener: SignalsListener): this;
366
- addListener(event: "newListener", listener: NewListenerListener): this;
367
- addListener(event: "removeListener", listener: RemoveListenerListener): this;
368
371
  addListener(event: "multipleResolves", listener: MultipleResolveListener): this;
372
+ addListener(event: "worker", listener: WorkerListener): this;
369
373
 
370
374
  emit(event: "beforeExit", code: number): boolean;
371
375
  emit(event: "disconnect"): boolean;
372
376
  emit(event: "exit", code: number): boolean;
373
- emit(event: "rejectionHandled", promise: Promise<any>): boolean;
377
+ emit(event: "rejectionHandled", promise: Promise<unknown>): boolean;
374
378
  emit(event: "uncaughtException", error: Error): boolean;
375
379
  emit(event: "uncaughtExceptionMonitor", error: Error): boolean;
376
- emit(event: "unhandledRejection", reason: any, promise: Promise<any>): boolean;
380
+ emit(event: "unhandledRejection", reason: unknown, promise: Promise<unknown>): boolean;
377
381
  emit(event: "warning", warning: Error): boolean;
378
- emit(event: "message", message: any, sendHandle: any): this;
382
+ emit(event: "message", message: unknown, sendHandle: unknown): this;
379
383
  emit(event: Signals, signal: Signals): boolean;
380
- emit(event: "newListener", eventName: string | symbol, listener: (...args: any[]) => void): this;
381
- emit(event: "removeListener", eventName: string, listener: (...args: any[]) => void): this;
382
- emit(event: "multipleResolves", listener: MultipleResolveListener): this;
384
+ emit(event: "multipleResolves", type: MultipleResolveType, promise: Promise<unknown>, value: unknown): this;
385
+ emit(event: "worker", listener: WorkerListener): this;
383
386
 
384
387
  on(event: "beforeExit", listener: BeforeExitListener): this;
385
388
  on(event: "disconnect", listener: DisconnectListener): this;
@@ -391,9 +394,8 @@ declare module 'process' {
391
394
  on(event: "warning", listener: WarningListener): this;
392
395
  on(event: "message", listener: MessageListener): this;
393
396
  on(event: Signals, listener: SignalsListener): this;
394
- on(event: "newListener", listener: NewListenerListener): this;
395
- on(event: "removeListener", listener: RemoveListenerListener): this;
396
397
  on(event: "multipleResolves", listener: MultipleResolveListener): this;
398
+ on(event: "worker", listener: WorkerListener): this;
397
399
  on(event: string | symbol, listener: (...args: any[]) => void): this;
398
400
 
399
401
  once(event: "beforeExit", listener: BeforeExitListener): this;
@@ -406,9 +408,9 @@ declare module 'process' {
406
408
  once(event: "warning", listener: WarningListener): this;
407
409
  once(event: "message", listener: MessageListener): this;
408
410
  once(event: Signals, listener: SignalsListener): this;
409
- once(event: "newListener", listener: NewListenerListener): this;
410
- once(event: "removeListener", listener: RemoveListenerListener): this;
411
411
  once(event: "multipleResolves", listener: MultipleResolveListener): this;
412
+ once(event: "worker", listener: WorkerListener): this;
413
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
412
414
 
413
415
  prependListener(event: "beforeExit", listener: BeforeExitListener): this;
414
416
  prependListener(event: "disconnect", listener: DisconnectListener): this;
@@ -420,9 +422,8 @@ declare module 'process' {
420
422
  prependListener(event: "warning", listener: WarningListener): this;
421
423
  prependListener(event: "message", listener: MessageListener): this;
422
424
  prependListener(event: Signals, listener: SignalsListener): this;
423
- prependListener(event: "newListener", listener: NewListenerListener): this;
424
- prependListener(event: "removeListener", listener: RemoveListenerListener): this;
425
425
  prependListener(event: "multipleResolves", listener: MultipleResolveListener): this;
426
+ prependListener(event: "worker", listener: WorkerListener): this;
426
427
 
427
428
  prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this;
428
429
  prependOnceListener(event: "disconnect", listener: DisconnectListener): this;
@@ -434,9 +435,8 @@ declare module 'process' {
434
435
  prependOnceListener(event: "warning", listener: WarningListener): this;
435
436
  prependOnceListener(event: "message", listener: MessageListener): this;
436
437
  prependOnceListener(event: Signals, listener: SignalsListener): this;
437
- prependOnceListener(event: "newListener", listener: NewListenerListener): this;
438
- prependOnceListener(event: "removeListener", listener: RemoveListenerListener): this;
439
438
  prependOnceListener(event: "multipleResolves", listener: MultipleResolveListener): this;
439
+ prependOnceListener(event: "worker", listener: WorkerListener): this;
440
440
 
441
441
  listeners(event: "beforeExit"): BeforeExitListener[];
442
442
  listeners(event: "disconnect"): DisconnectListener[];
@@ -448,9 +448,8 @@ declare module 'process' {
448
448
  listeners(event: "warning"): WarningListener[];
449
449
  listeners(event: "message"): MessageListener[];
450
450
  listeners(event: Signals): SignalsListener[];
451
- listeners(event: "newListener"): NewListenerListener[];
452
- listeners(event: "removeListener"): RemoveListenerListener[];
453
451
  listeners(event: "multipleResolves"): MultipleResolveListener[];
452
+ listeners(event: "worker"): WorkerListener[];
454
453
  }
455
454
  }
456
455
  }
node/ts3.6/base.d.ts CHANGED
@@ -55,7 +55,6 @@
55
55
  /// <reference path="../tty.d.ts" />
56
56
  /// <reference path="../url.d.ts" />
57
57
  /// <reference path="../util.d.ts" />
58
- /// <reference path="../util/types.d.ts" />
59
58
  /// <reference path="../v8.d.ts" />
60
59
  /// <reference path="../vm.d.ts" />
61
60
  /// <reference path="../worker_threads.d.ts" />
node/util.d.ts CHANGED
@@ -200,3 +200,65 @@ declare module 'util' {
200
200
  declare module 'node:util' {
201
201
  export * from 'util';
202
202
  }
203
+
204
+ declare module 'util/types' {
205
+ import { KeyObject, webcrypto } from 'crypto';
206
+
207
+ function isAnyArrayBuffer(object: unknown): object is ArrayBufferLike;
208
+ function isArgumentsObject(object: unknown): object is IArguments;
209
+ function isArrayBuffer(object: unknown): object is ArrayBuffer;
210
+ function isArrayBufferView(object: unknown): object is NodeJS.ArrayBufferView;
211
+ function isAsyncFunction(object: unknown): boolean;
212
+ function isBigInt64Array(value: unknown): value is BigInt64Array;
213
+ function isBigUint64Array(value: unknown): value is BigUint64Array;
214
+ function isBooleanObject(object: unknown): object is Boolean;
215
+ function isBoxedPrimitive(object: unknown): object is String | Number | BigInt | Boolean | Symbol;
216
+ function isDataView(object: unknown): object is DataView;
217
+ function isDate(object: unknown): object is Date;
218
+ function isExternal(object: unknown): boolean;
219
+ function isFloat32Array(object: unknown): object is Float32Array;
220
+ function isFloat64Array(object: unknown): object is Float64Array;
221
+ function isGeneratorFunction(object: unknown): object is GeneratorFunction;
222
+ function isGeneratorObject(object: unknown): object is Generator;
223
+ function isInt8Array(object: unknown): object is Int8Array;
224
+ function isInt16Array(object: unknown): object is Int16Array;
225
+ function isInt32Array(object: unknown): object is Int32Array;
226
+ function isMap<T>(
227
+ object: T | {},
228
+ ): object is T extends ReadonlyMap<any, any>
229
+ ? unknown extends T
230
+ ? never
231
+ : ReadonlyMap<any, any>
232
+ : Map<unknown, unknown>;
233
+ function isMapIterator(object: unknown): boolean;
234
+ function isModuleNamespaceObject(value: unknown): boolean;
235
+ function isNativeError(object: unknown): object is Error;
236
+ function isNumberObject(object: unknown): object is Number;
237
+ function isPromise(object: unknown): object is Promise<unknown>;
238
+ function isProxy(object: unknown): boolean;
239
+ function isRegExp(object: unknown): object is RegExp;
240
+ function isSet<T>(
241
+ object: T | {},
242
+ ): object is T extends ReadonlySet<any>
243
+ ? unknown extends T
244
+ ? never
245
+ : ReadonlySet<any>
246
+ : Set<unknown>;
247
+ function isSetIterator(object: unknown): boolean;
248
+ function isSharedArrayBuffer(object: unknown): object is SharedArrayBuffer;
249
+ function isStringObject(object: unknown): object is String;
250
+ function isSymbolObject(object: unknown): object is Symbol;
251
+ function isTypedArray(object: unknown): object is NodeJS.TypedArray;
252
+ function isUint8Array(object: unknown): object is Uint8Array;
253
+ function isUint8ClampedArray(object: unknown): object is Uint8ClampedArray;
254
+ function isUint16Array(object: unknown): object is Uint16Array;
255
+ function isUint32Array(object: unknown): object is Uint32Array;
256
+ function isWeakMap(object: unknown): object is WeakMap<object, unknown>;
257
+ function isWeakSet(object: unknown): object is WeakSet<object>;
258
+ function isKeyObject(object: unknown): object is KeyObject;
259
+ function isCryptoKey(object: unknown): object is webcrypto.CryptoKey;
260
+ }
261
+
262
+ declare module 'node:util/types' {
263
+ export * from 'util/types';
264
+ }
node/util/types.d.ts DELETED
@@ -1,57 +0,0 @@
1
- declare module 'util/types' {
2
- function isAnyArrayBuffer(object: unknown): object is ArrayBufferLike;
3
- function isArgumentsObject(object: unknown): object is IArguments;
4
- function isArrayBuffer(object: unknown): object is ArrayBuffer;
5
- function isArrayBufferView(object: unknown): object is NodeJS.ArrayBufferView;
6
- function isAsyncFunction(object: unknown): boolean;
7
- function isBigInt64Array(value: unknown): value is BigInt64Array;
8
- function isBigUint64Array(value: unknown): value is BigUint64Array;
9
- function isBooleanObject(object: unknown): object is Boolean;
10
- function isBoxedPrimitive(object: unknown): object is String | Number | BigInt | Boolean | Symbol;
11
- function isDataView(object: unknown): object is DataView;
12
- function isDate(object: unknown): object is Date;
13
- function isExternal(object: unknown): boolean;
14
- function isFloat32Array(object: unknown): object is Float32Array;
15
- function isFloat64Array(object: unknown): object is Float64Array;
16
- function isGeneratorFunction(object: unknown): object is GeneratorFunction;
17
- function isGeneratorObject(object: unknown): object is Generator;
18
- function isInt8Array(object: unknown): object is Int8Array;
19
- function isInt16Array(object: unknown): object is Int16Array;
20
- function isInt32Array(object: unknown): object is Int32Array;
21
- function isMap<T>(
22
- object: T | {},
23
- ): object is T extends ReadonlyMap<any, any>
24
- ? unknown extends T
25
- ? never
26
- : ReadonlyMap<any, any>
27
- : Map<unknown, unknown>;
28
- function isMapIterator(object: unknown): boolean;
29
- function isModuleNamespaceObject(value: unknown): boolean;
30
- function isNativeError(object: unknown): object is Error;
31
- function isNumberObject(object: unknown): object is Number;
32
- function isPromise(object: unknown): object is Promise<unknown>;
33
- function isProxy(object: unknown): boolean;
34
- function isRegExp(object: unknown): object is RegExp;
35
- function isSet<T>(
36
- object: T | {},
37
- ): object is T extends ReadonlySet<any>
38
- ? unknown extends T
39
- ? never
40
- : ReadonlySet<any>
41
- : Set<unknown>;
42
- function isSetIterator(object: unknown): boolean;
43
- function isSharedArrayBuffer(object: unknown): object is SharedArrayBuffer;
44
- function isStringObject(object: unknown): object is String;
45
- function isSymbolObject(object: unknown): object is Symbol;
46
- function isTypedArray(object: unknown): object is NodeJS.TypedArray;
47
- function isUint8Array(object: unknown): object is Uint8Array;
48
- function isUint8ClampedArray(object: unknown): object is Uint8ClampedArray;
49
- function isUint16Array(object: unknown): object is Uint16Array;
50
- function isUint32Array(object: unknown): object is Uint32Array;
51
- function isWeakMap(object: unknown): object is WeakMap<object, unknown>;
52
- function isWeakSet(object: unknown): object is WeakSet<object>;
53
- }
54
-
55
- declare module 'node:util/types' {
56
- export * from 'util/types';
57
- }