Skip to content

Commit 0f744c8

Browse files
cjbarthblakeembrey
authored andcommitted
Add null as acceptable value for options parameter in fs namespace (#47)
1 parent e223bbb commit 0f744c8

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

4.0/node.d.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,12 +1711,12 @@ declare module "fs" {
17111711
* Asynchronously append data to a file, creating the file if it does not yet exist. `data` can be a string or a buffer.
17121712
*/
17131713
export function appendFile(file: string | number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void;
1714-
export function appendFile(file: string | number, data: string | Buffer, options: buffer.Encoding | AppendFileOptions, callback: (err: NodeJS.ErrnoException | null) => void): void;
1714+
export function appendFile(file: string | number, data: string | Buffer, options: buffer.Encoding | AppendFileOptions | null, callback: (err: NodeJS.ErrnoException | null) => void): void;
17151715

17161716
/**
17171717
* The synchronous version of `fs.appendFile()`.
17181718
*/
1719-
export function appendFileSync(file: string | number, data: string | Buffer, options?: AppendFileOptions): void;
1719+
export function appendFileSync(file: string | number, data: string | Buffer, options?: AppendFileOptions | null): void;
17201720

17211721
/**
17221722
* Asynchronous chmod(2).
@@ -1763,7 +1763,7 @@ declare module "fs" {
17631763
*
17641764
* Be aware that, unlike the default value set for `highWaterMark` on a readable stream (16 kb), the stream returned by this method has a default value of 64 kb for the same parameter.
17651765
*/
1766-
export function createReadStream(path: string, options?: ReadStreamOptions): ReadStream;
1766+
export function createReadStream(path: string, options?: ReadStreamOptions | null): ReadStream;
17671767

17681768
export interface WriteStreamOptions {
17691769
flags?: string;
@@ -1778,7 +1778,7 @@ declare module "fs" {
17781778
/**
17791779
* Returns a new WriteStream object.
17801780
*/
1781-
export function createWriteStream(path: string, options?: WriteStreamOptions): WriteStream;
1781+
export function createWriteStream(path: string, options?: WriteStreamOptions | null): WriteStream;
17821782

17831783
/**
17841784
* Test whether or not the given path exists by checking with the file system. Then call the `callback` argument with either true or false.
@@ -1986,13 +1986,13 @@ declare module "fs" {
19861986
* @param files is an array of the names of the files in the directory excluding '.' and '..'.
19871987
*/
19881988
export function readdir(path: string, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
1989-
export function readdir(path: string, options: buffer.Encoding | ReaddirOptions, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
1989+
export function readdir(path: string, options: buffer.Encoding | ReaddirOptions | null, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
19901990

19911991
/**
19921992
* Synchronous readdir(3). Returns an array of filenames excluding '.' and '..'.
19931993
*/
19941994
export function readdirSync(path: string): string[];
1995-
export function readdirSync(path: string, options: buffer.Encoding | ReaddirOptions): string[];
1995+
export function readdirSync(path: string, options: buffer.Encoding | ReaddirOptions | null): string[];
19961996

19971997
export interface ReadFileOptions {
19981998
encoding?: buffer.Encoding;
@@ -2004,14 +2004,14 @@ declare module "fs" {
20042004
*/
20052005
export function readFile(filename: string, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
20062006
export function readFile(filename: string, options: buffer.Encoding | (ReadFileOptions & { encoding: buffer.Encoding }), callback: (err: NodeJS.ErrnoException | null, data: string) => void): void;
2007-
export function readFile(filename: string, options: ReadFileOptions, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
2007+
export function readFile(filename: string, options: ReadFileOptions | null, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
20082008

20092009
/**
20102010
* Synchronous version of `fs.readFile`.
20112011
*/
20122012
export function readFileSync(filename: string): Buffer;
20132013
export function readFileSync(filename: string, options: buffer.Encoding | (ReadFileOptions & { encoding: buffer.Encoding })): string;
2014-
export function readFileSync(filename: string, options: ReadFileOptions): Buffer;
2014+
export function readFileSync(filename: string, options: ReadFileOptions | null): Buffer;
20152015

20162016
export interface ReadlinkOptions {
20172017
encoding?: buffer.Encoding;
@@ -2021,13 +2021,13 @@ declare module "fs" {
20212021
* Asynchronous readlink(2).
20222022
*/
20232023
export function readlink(path: string, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void;
2024-
export function readlink(path: string, options: buffer.Encoding | ReadlinkOptions, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void;
2024+
export function readlink(path: string, options: buffer.Encoding | ReadlinkOptions | null, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void;
20252025

20262026
/**
20272027
* Synchronous readlink(2).
20282028
*/
20292029
export function readlinkSync(path: string): string;
2030-
export function readlinkSync(path: string, options: buffer.Encoding | ReadlinkOptions): string;
2030+
export function readlinkSync(path: string, options: buffer.Encoding | ReadlinkOptions | null): string;
20312031

20322032
/**
20332033
* Synchronous version of `fs.read()`.
@@ -2044,15 +2044,15 @@ declare module "fs" {
20442044
* Only paths that can be converted to UTF8 strings are supported.
20452045
*/
20462046
export function realpath(path: string, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
2047-
export function realpath(path: string, options: buffer.Encoding | RealpathOptions, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
2047+
export function realpath(path: string, options: buffer.Encoding | RealpathOptions | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
20482048

20492049
/**
20502050
* Synchronous realpath(3). Returns the resolved path.
20512051
*
20522052
* Only paths that can be converted to UTF8 strings are supported.
20532053
*/
20542054
export function realpathSync(path: string): string;
2055-
export function realpathSync(path: string, options: buffer.Encoding | RealpathOptions): string;
2055+
export function realpathSync(path: string, options: buffer.Encoding | RealpathOptions | null): string;
20562056

20572057
/**
20582058
* Asynchronous rename(2).
@@ -2167,9 +2167,9 @@ declare module "fs" {
21672167
* Please note the listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but they are not the same thing.
21682168
*/
21692169
export function watch(filename: string): FSWatcher;
2170-
export function watch(filename: string, options: buffer.Encoding | WatchOptions): FSWatcher;
2170+
export function watch(filename: string, options: buffer.Encoding | WatchOptions | null): FSWatcher;
21712171
export function watch(filename: string, listener: WatchListener): FSWatcher;
2172-
export function watch(filename: string, options: buffer.Encoding | WatchOptions, listener: WatchListener): FSWatcher;
2172+
export function watch(filename: string, options: buffer.Encoding | WatchOptions | null, listener: WatchListener): FSWatcher;
21732173

21742174
export interface WatchFileOptions {
21752175
/**
@@ -2190,7 +2190,7 @@ declare module "fs" {
21902190
* Note: `fs.watch()` is more efficient than `fs.watchFile` and `fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and `fs.unwatchFile` when possible.
21912191
*/
21922192
export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void;
2193-
export function watchFile(filename: string, options: WatchFileOptions, listener: (curr: Stats, prev: Stats) => void): void;
2193+
export function watchFile(filename: string, options: WatchFileOptions | null, listener: (curr: Stats, prev: Stats) => void): void;
21942194

21952195
/**
21962196
* Write `buffer` to the file specified by `fd`.
@@ -2223,12 +2223,12 @@ declare module "fs" {
22232223
* Note: If a file descriptor is specified as the `file`, it will not be closed automatically.
22242224
*/
22252225
export function writeFile(file: string | number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void;
2226-
export function writeFile(file: string | number, data: string | Buffer, options: buffer.Encoding | WriteFileOptions, callback: (err: NodeJS.ErrnoException | null) => void): void;
2226+
export function writeFile(file: string | number, data: string | Buffer, options: buffer.Encoding | WriteFileOptions | null, callback: (err: NodeJS.ErrnoException | null) => void): void;
22272227

22282228
/**
22292229
* The synchronous version of `fs.writeFile()`.
22302230
*/
2231-
export function writeFileSync(file: string | number, data: string | Buffer, options?: buffer.Encoding | WriteFileOptions): void;
2231+
export function writeFileSync(file: string | number, data: string | Buffer, options?: buffer.Encoding | WriteFileOptions | null): void;
22322232

22332233
/**
22342234
* Synchronous `fs.write`.

6.0/node.d.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,12 +1795,12 @@ declare module "fs" {
17951795
* Asynchronously append data to a file, creating the file if it does not yet exist. `data` can be a string or a buffer.
17961796
*/
17971797
export function appendFile(file: string | Buffer | number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void;
1798-
export function appendFile(file: string | Buffer | number, data: string | Buffer, options: buffer.Encoding | AppendFileOptions, callback: (err: NodeJS.ErrnoException | null) => void): void;
1798+
export function appendFile(file: string | Buffer | number, data: string | Buffer, options: buffer.Encoding | AppendFileOptions | null, callback: (err: NodeJS.ErrnoException | null) => void): void;
17991799

18001800
/**
18011801
* The synchronous version of `fs.appendFile()`.
18021802
*/
1803-
export function appendFileSync(file: string | Buffer | number, data: string | Buffer, options?: AppendFileOptions): void;
1803+
export function appendFileSync(file: string | Buffer | number, data: string | Buffer, options?: AppendFileOptions | null): void;
18041804

18051805
/**
18061806
* Asynchronous chmod(2).
@@ -1847,7 +1847,7 @@ declare module "fs" {
18471847
*
18481848
* Be aware that, unlike the default value set for `highWaterMark` on a readable stream (16 kb), the stream returned by this method has a default value of 64 kb for the same parameter.
18491849
*/
1850-
export function createReadStream(path: string | Buffer, options?: ReadStreamOptions): ReadStream;
1850+
export function createReadStream(path: string | Buffer, options?: ReadStreamOptions | null): ReadStream;
18511851

18521852
export interface WriteStreamOptions {
18531853
flags?: string;
@@ -1862,7 +1862,7 @@ declare module "fs" {
18621862
/**
18631863
* Returns a new WriteStream object.
18641864
*/
1865-
export function createWriteStream(path: string | Buffer, options?: WriteStreamOptions): WriteStream;
1865+
export function createWriteStream(path: string | Buffer, options?: WriteStreamOptions | null): WriteStream;
18661866

18671867
/**
18681868
* Test whether or not the given path exists by checking with the file system. Then call the `callback` argument with either true or false.
@@ -2023,12 +2023,12 @@ declare module "fs" {
20232023
* The created folder path is passed as a string to the callback's second parameter.
20242024
*/
20252025
export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, dir: string) => void): void;
2026-
export function mkdtemp(prefix: string, options: buffer.Encoding | MkdtempOptions, callback: (err: NodeJS.ErrnoException | null, dir: string) => void): void;
2026+
export function mkdtemp(prefix: string, options: buffer.Encoding | MkdtempOptions | null, callback: (err: NodeJS.ErrnoException | null, dir: string) => void): void;
20272027

20282028
/**
20292029
* The synchronous version of fs.mkdtemp(). Returns the created folder path.
20302030
*/
2031-
export function mkdtempSync(prefix: string, options?: buffer.Encoding | MkdtempOptions): string;
2031+
export function mkdtempSync(prefix: string, options?: buffer.Encoding | MkdtempOptions | null): string;
20322032

20332033
/**
20342034
* Asynchronous file open. See open(2). `flags` can be:
@@ -2090,14 +2090,14 @@ declare module "fs" {
20902090
*/
20912091
export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
20922092
export function readdir(path: string | Buffer, options: 'buffer' | (ReadFileOptions & { encoding: 'buffer' }), callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void): void;
2093-
export function readdir(path: string | Buffer, options: buffer.Encoding | ReaddirOptions, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
2093+
export function readdir(path: string | Buffer, options: buffer.Encoding | ReaddirOptions | null, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
20942094

20952095
/**
20962096
* Synchronous readdir(3). Returns an array of filenames excluding '.' and '..'.
20972097
*/
20982098
export function readdirSync(path: string | Buffer): string[];
20992099
export function readdirSync(path: string | Buffer, options: 'buffer' | (ReaddirOptions & { encoding: 'buffer' })): Buffer[];
2100-
export function readdirSync(path: string | Buffer, options: buffer.Encoding | ReaddirOptions): string[];
2100+
export function readdirSync(path: string | Buffer, options: buffer.Encoding | ReaddirOptions | null): string[];
21012101

21022102
export interface ReadFileOptions {
21032103
encoding?: buffer.Encoding | 'buffer';
@@ -2109,14 +2109,14 @@ declare module "fs" {
21092109
*/
21102110
export function readFile(file: string | Buffer | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
21112111
export function readFile(file: string | Buffer | number, options: buffer.Encoding | (ReadFileOptions & { encoding: buffer.Encoding }), callback: (err: NodeJS.ErrnoException | null, data: string) => void): void;
2112-
export function readFile(file: string | Buffer | number, options: 'buffer' | ReadFileOptions, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
2112+
export function readFile(file: string | Buffer | number, options: 'buffer' | ReadFileOptions | null, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
21132113

21142114
/**
21152115
* Synchronous version of `fs.readFile`.
21162116
*/
21172117
export function readFileSync(file: string | Buffer | number): Buffer;
21182118
export function readFileSync(file: string | Buffer | number, options: buffer.Encoding | (ReadFileOptions & { encoding: buffer.Encoding })): string;
2119-
export function readFileSync(file: string | Buffer | number, options: 'buffer' | ReadFileOptions): Buffer;
2119+
export function readFileSync(file: string | Buffer | number, options: 'buffer' | ReadFileOptions | null): Buffer;
21202120

21212121
export interface ReadlinkOptions {
21222122
encoding?: buffer.Encoding | 'buffer';
@@ -2127,14 +2127,14 @@ declare module "fs" {
21272127
*/
21282128
export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void;
21292129
export function readlink(path: string | Buffer, options: 'buffer' | (ReadlinkOptions & { encoding: 'buffer' }), callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void;
2130-
export function readlink(path: string | Buffer, options: buffer.Encoding | ReadlinkOptions, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void;
2130+
export function readlink(path: string | Buffer, options: buffer.Encoding | ReadlinkOptions | null, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void;
21312131

21322132
/**
21332133
* Synchronous readlink(2).
21342134
*/
21352135
export function readlinkSync(path: string | Buffer): string;
21362136
export function readlinkSync(path: string | Buffer, options: 'buffer' | (ReadlinkOptions & { encoding: 'buffer' })): Buffer;
2137-
export function readlinkSync(path: string | Buffer, options: buffer.Encoding | ReadlinkOptions): string;
2137+
export function readlinkSync(path: string | Buffer, options: buffer.Encoding | ReadlinkOptions | null): string;
21382138

21392139
/**
21402140
* Synchronous version of `fs.read()`.
@@ -2152,7 +2152,7 @@ declare module "fs" {
21522152
*/
21532153
export function realpath(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
21542154
export function realpath(path: string | Buffer, options: 'buffer' | (RealpathOptions & { encoding: 'buffer' }), callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
2155-
export function realpath(path: string | Buffer, options: buffer.Encoding | RealpathOptions, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
2155+
export function realpath(path: string | Buffer, options: buffer.Encoding | RealpathOptions | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
21562156

21572157
/**
21582158
* Synchronous realpath(3). Returns the resolved path.
@@ -2161,7 +2161,7 @@ declare module "fs" {
21612161
*/
21622162
export function realpathSync(path: string | Buffer): string;
21632163
export function realpathSync(path: string | Buffer, options: 'buffer' | (RealpathOptions & { encoding: 'buffer' })): Buffer;
2164-
export function realpathSync(path: string | Buffer, options: buffer.Encoding | RealpathOptions): string;
2164+
export function realpathSync(path: string | Buffer, options: buffer.Encoding | RealpathOptions | null): string;
21652165

21662166
/**
21672167
* Asynchronous rename(2).
@@ -2276,9 +2276,9 @@ declare module "fs" {
22762276
* Please note the listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but they are not the same thing.
22772277
*/
22782278
export function watch(filename: string | Buffer): FSWatcher;
2279-
export function watch(filename: string | Buffer, options: buffer.Encoding | WatchOptions): FSWatcher;
2279+
export function watch(filename: string | Buffer, options: buffer.Encoding | WatchOptions | null): FSWatcher;
22802280
export function watch(filename: string | Buffer, listener: WatchListener): FSWatcher;
2281-
export function watch(filename: string | Buffer, options: buffer.Encoding | WatchOptions, listener: WatchListener): FSWatcher;
2281+
export function watch(filename: string | Buffer, options: buffer.Encoding | WatchOptions | null, listener: WatchListener): FSWatcher;
22822282

22832283
export interface WatchFileOptions {
22842284
/**
@@ -2299,7 +2299,7 @@ declare module "fs" {
22992299
* Note: `fs.watch()` is more efficient than `fs.watchFile` and `fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and `fs.unwatchFile` when possible.
23002300
*/
23012301
export function watchFile(filename: string | Buffer, listener: (curr: Stats, prev: Stats) => void): void;
2302-
export function watchFile(filename: string | Buffer, options: WatchFileOptions, listener: (curr: Stats, prev: Stats) => void): void;
2302+
export function watchFile(filename: string | Buffer, options: WatchFileOptions | null, listener: (curr: Stats, prev: Stats) => void): void;
23032303

23042304
/**
23052305
* Write `buffer` to the file specified by `fd`.
@@ -2332,12 +2332,12 @@ declare module "fs" {
23322332
* Note: If a file descriptor is specified as the `file`, it will not be closed automatically.
23332333
*/
23342334
export function writeFile(file: string | Buffer | number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void;
2335-
export function writeFile(file: string | Buffer | number, data: string | Buffer, options: buffer.Encoding | WriteFileOptions, callback: (err: NodeJS.ErrnoException | null) => void): void;
2335+
export function writeFile(file: string | Buffer | number, data: string | Buffer, options: buffer.Encoding | WriteFileOptions | null, callback: (err: NodeJS.ErrnoException | null) => void): void;
23362336

23372337
/**
23382338
* The synchronous version of `fs.writeFile()`.
23392339
*/
2340-
export function writeFileSync(file: string | Buffer | number, data: string | Buffer, options?: buffer.Encoding | WriteFileOptions): void;
2340+
export function writeFileSync(file: string | Buffer | number, data: string | Buffer, options?: buffer.Encoding | WriteFileOptions | null): void;
23412341

23422342
/**
23432343
* Synchronous `fs.write`.

0 commit comments

Comments
 (0)