From 65df3226ec65d41415035f1ae44f7fd8499d0d48 Mon Sep 17 00:00:00 2001 From: Donald Pipowitch Date: Wed, 8 Nov 2017 10:08:29 +0100 Subject: [PATCH] updated writeFile and outputFile in fs-extra --- types/fs-extra/index.d.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/types/fs-extra/index.d.ts b/types/fs-extra/index.d.ts index 84548e48a4..7120ebf409 100644 --- a/types/fs-extra/index.d.ts +++ b/types/fs-extra/index.d.ts @@ -37,10 +37,11 @@ export function mkdirp(dir: string): Promise; export function mkdirp(dir: string, callback: (err: Error | null) => void): void; export function mkdirsSync(dir: string): void; export function mkdirpSync(dir: string): void; - -export function outputFile(file: string, data: any): Promise; + +export function outputFile(file: string, data: any, options?: WriteFileOptions | string): Promise; export function outputFile(file: string, data: any, callback: (err: Error | null) => void): void; -export function outputFileSync(file: string, data: any): void; +export function outputFile(file: string, data: any, options: WriteFileOptions | string, callback: (err: Error | null) => void): void; +export function outputFileSync(file: string, data: any, options?: WriteFileOptions | string): void; export function readJson(file: string, options?: ReadOptions): Promise; export function readJson(file: string, callback: (err: Error | null, jsonObject: any) => void): void; @@ -234,8 +235,8 @@ export function write(fd: number, buffer: Buffer, offset: number, length: number export function write(fd: number, data: any, offset: number, encoding?: string): Promise; export function writeFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException | null) => void): void; -export function writeFile(file: string | Buffer | number, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): Promise; -export function writeFile(file: string | Buffer | number, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback: (err: NodeJS.ErrnoException | null) => void): void; +export function writeFile(file: string | Buffer | number, data: any, options?: WriteFileOptions | string): Promise; +export function writeFile(file: string | Buffer | number, data: any, options: WriteFileOptions | string, callback: (err: NodeJS.ErrnoException | null) => void): void; /** * Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. @@ -279,16 +280,19 @@ export interface ReadOptions { encoding?: string; flag?: string; } - -export interface WriteOptions { - fs?: object; - replacer?: any; - spaces?: number; + +export interface WriteFileOptions { encoding?: string; flag?: string; mode?: number; } +export interface WriteOptions extends WriteFileOptions { + fs?: object; + replacer?: any; + spaces?: number; +} + export interface ReadResult { bytesRead: number; buffer: Buffer;