diff --git a/types/fs-extra/fs-extra-tests.ts b/types/fs-extra/fs-extra-tests.ts index 50d594e1a4..dbe48cf971 100644 --- a/types/fs-extra/fs-extra-tests.ts +++ b/types/fs-extra/fs-extra-tests.ts @@ -48,7 +48,7 @@ fs.copy(src, dest, { overwrite: true, preserveTimestamps: true, - filter: (src: string, dest: string) => false + filter: (src: string, dest: string) => Promise.resolve(false) }, errorCallback ); diff --git a/types/fs-extra/index.d.ts b/types/fs-extra/index.d.ts index 6183dce393..adf236955b 100644 --- a/types/fs-extra/index.d.ts +++ b/types/fs-extra/index.d.ts @@ -3,7 +3,8 @@ // Definitions by: Alan Agius , // midknight41 , // Brendan Forster , -// Mees van Dijk +// Mees van Dijk , +// Justin Rockwood // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -16,7 +17,7 @@ export * from "fs"; export function copy(src: string, dest: string, options?: CopyOptions): Promise; export function copy(src: string, dest: string, callback: (err: Error) => void): void; export function copy(src: string, dest: string, options: CopyOptions, callback: (err: Error) => void): void; -export function copySync(src: string, dest: string, options?: CopyOptions): void; +export function copySync(src: string, dest: string, options?: CopyOptionsSync): void; export function move(src: string, dest: string, options?: MoveOptions): Promise; export function move(src: string, dest: string, callback: (err: Error) => void): void; @@ -254,7 +255,8 @@ export interface PathEntryStream { read(): PathEntry | null; } -export type CopyFilter = (src: string, dest: string) => boolean; +export type CopyFilterSync = (src: string, dest: string) => boolean; +export type CopyFilterAsync = (src: string, dest: string) => Promise; export type SymlinkType = "dir" | "file"; @@ -263,10 +265,14 @@ export interface CopyOptions { overwrite?: boolean; preserveTimestamps?: boolean; errorOnExist?: boolean; - filter?: CopyFilter; + filter?: CopyFilterSync | CopyFilterAsync; recursive?: boolean; } +export interface CopyOptionsSync extends CopyOptions { + filter?: CopyFilterSync; +} + export interface MoveOptions { overwrite?: boolean; limit?: number;