@types/node 16.0.2 → 16.3.2

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: Thu, 08 Jul 2021 22:41:05 GMT
11
+ * Last updated: Wed, 14 Jul 2021 00:01:20 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/buffer.d.ts CHANGED
@@ -91,7 +91,7 @@ declare module 'buffer' {
91
91
  * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
92
92
  * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
93
93
  */
94
- class Buffer extends Uint8Array {
94
+ interface BufferConstructor {
95
95
  /**
96
96
  * Allocates a new buffer containing the given {str}.
97
97
  *
@@ -99,21 +99,21 @@ declare module 'buffer' {
99
99
  * @param encoding encoding to use, optional. Default is 'utf8'
100
100
  * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
101
101
  */
102
- constructor(str: string, encoding?: BufferEncoding);
102
+ new(str: string, encoding?: BufferEncoding): Buffer;
103
103
  /**
104
104
  * Allocates a new buffer of {size} octets.
105
105
  *
106
106
  * @param size count of octets to allocate.
107
107
  * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
108
108
  */
109
- constructor(size: number);
109
+ new(size: number): Buffer;
110
110
  /**
111
111
  * Allocates a new buffer containing the given {array} of octets.
112
112
  *
113
113
  * @param array The octets to store.
114
114
  * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
115
115
  */
116
- constructor(array: Uint8Array);
116
+ new(array: Uint8Array): Buffer;
117
117
  /**
118
118
  * Produces a Buffer backed by the same allocated memory as
119
119
  * the given {ArrayBuffer}/{SharedArrayBuffer}.
@@ -122,21 +122,21 @@ declare module 'buffer' {
122
122
  * @param arrayBuffer The ArrayBuffer with which to share memory.
123
123
  * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
124
124
  */
125
- constructor(arrayBuffer: ArrayBuffer | SharedArrayBuffer);
125
+ new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
126
126
  /**
127
127
  * Allocates a new buffer containing the given {array} of octets.
128
128
  *
129
129
  * @param array The octets to store.
130
130
  * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
131
131
  */
132
- constructor(array: ReadonlyArray<any>);
132
+ new(array: ReadonlyArray<any>): Buffer;
133
133
  /**
134
134
  * Copies the passed {buffer} data onto a new {Buffer} instance.
135
135
  *
136
136
  * @param buffer The buffer to copy.
137
137
  * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
138
138
  */
139
- constructor(buffer: Buffer);
139
+ new(buffer: Buffer): Buffer;
140
140
  /**
141
141
  * When passed a reference to the .buffer property of a TypedArray instance,
142
142
  * the newly created Buffer will share the same allocated memory as the TypedArray.
@@ -145,37 +145,37 @@ declare module 'buffer' {
145
145
  *
146
146
  * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
147
147
  */
148
- static from(arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>, byteOffset?: number, length?: number): Buffer;
148
+ from(arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>, byteOffset?: number, length?: number): Buffer;
149
149
  /**
150
150
  * Creates a new Buffer using the passed {data}
151
151
  * @param data data to create a new Buffer
152
152
  */
153
- static from(data: Uint8Array | ReadonlyArray<number>): Buffer;
154
- static from(data: WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string>): Buffer;
153
+ from(data: Uint8Array | ReadonlyArray<number>): Buffer;
154
+ from(data: WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string>): Buffer;
155
155
  /**
156
156
  * Creates a new Buffer containing the given JavaScript string {str}.
157
157
  * If provided, the {encoding} parameter identifies the character encoding.
158
158
  * If not provided, {encoding} defaults to 'utf8'.
159
159
  */
160
- static from(str: WithImplicitCoercion<string> | { [Symbol.toPrimitive](hint: 'string'): string }, encoding?: BufferEncoding): Buffer;
160
+ from(str: WithImplicitCoercion<string> | { [Symbol.toPrimitive](hint: 'string'): string }, encoding?: BufferEncoding): Buffer;
161
161
  /**
162
162
  * Creates a new Buffer using the passed {data}
163
163
  * @param values to create a new Buffer
164
164
  */
165
- static of(...items: number[]): Buffer;
165
+ of(...items: number[]): Buffer;
166
166
  /**
167
167
  * Returns true if {obj} is a Buffer
168
168
  *
169
169
  * @param obj object to test.
170
170
  */
171
- static isBuffer(obj: any): obj is Buffer;
171
+ isBuffer(obj: any): obj is Buffer;
172
172
  /**
173
173
  * Returns true if {encoding} is a valid encoding argument.
174
174
  * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
175
175
  *
176
176
  * @param encoding string to test.
177
177
  */
178
- static isEncoding(encoding: string): encoding is BufferEncoding;
178
+ isEncoding(encoding: string): encoding is BufferEncoding;
179
179
  /**
180
180
  * Gives the actual byte length of a string. encoding defaults to 'utf8'.
181
181
  * This is not the same as String.prototype.length since that returns the number of characters in a string.
@@ -183,7 +183,7 @@ declare module 'buffer' {
183
183
  * @param string string to test.
184
184
  * @param encoding encoding used to evaluate (defaults to 'utf8')
185
185
  */
186
- static byteLength(
186
+ byteLength(
187
187
  string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
188
188
  encoding?: BufferEncoding
189
189
  ): number;
@@ -198,11 +198,11 @@ declare module 'buffer' {
198
198
  * @param totalLength Total length of the buffers when concatenated.
199
199
  * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
200
200
  */
201
- static concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
201
+ concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
202
202
  /**
203
203
  * The same as buf1.compare(buf2).
204
204
  */
205
- static compare(buf1: Uint8Array, buf2: Uint8Array): number;
205
+ compare(buf1: Uint8Array, buf2: Uint8Array): number;
206
206
  /**
207
207
  * Allocates a new buffer of {size} octets.
208
208
  *
@@ -211,26 +211,28 @@ declare module 'buffer' {
211
211
  * If parameter is omitted, buffer will be filled with zeros.
212
212
  * @param encoding encoding used for call to buf.fill while initalizing
213
213
  */
214
- static alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
214
+ alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
215
215
  /**
216
216
  * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
217
217
  * of the newly created Buffer are unknown and may contain sensitive data.
218
218
  *
219
219
  * @param size count of octets to allocate
220
220
  */
221
- static allocUnsafe(size: number): Buffer;
221
+ allocUnsafe(size: number): Buffer;
222
222
  /**
223
223
  * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
224
224
  * of the newly created Buffer are unknown and may contain sensitive data.
225
225
  *
226
226
  * @param size count of octets to allocate
227
227
  */
228
- static allocUnsafeSlow(size: number): Buffer;
228
+ allocUnsafeSlow(size: number): Buffer;
229
229
  /**
230
230
  * This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified.
231
231
  */
232
- static poolSize: number;
232
+ poolSize: number;
233
+ }
233
234
 
235
+ interface Buffer extends Uint8Array {
234
236
  write(string: string, encoding?: BufferEncoding): number;
235
237
  write(string: string, offset: number, encoding?: BufferEncoding): number;
236
238
  write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
@@ -321,6 +323,7 @@ declare module 'buffer' {
321
323
  keys(): IterableIterator<number>;
322
324
  values(): IterableIterator<number>;
323
325
  }
326
+ var Buffer: BufferConstructor;
324
327
 
325
328
  /**
326
329
  * Decodes a string of Base64-encoded data into bytes, and encodes those bytes into a string using Latin-1 (ISO-8859-1).
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
 
@@ -488,7 +488,7 @@ declare module 'child_process' {
488
488
  function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
489
489
  function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
490
490
 
491
- interface CommonExecOptions extends ProcessEnvOptions {
491
+ interface CommonExecOptions extends CommonOptions {
492
492
  input?: string | NodeJS.ArrayBufferView | undefined;
493
493
  stdio?: StdioOptions | undefined;
494
494
  killSignal?: NodeJS.Signals | number | undefined;
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