DefinitelyTyped/types/recursive-readdir/index.d.ts
Micah Zoltu 1eca915e24 Fixes definitions to match reality. (#19800)
Return type on ignore function was missing and Promise return type was missing from overloads that didn't take a callback.  Also extracts out a helper type definitions and provides slightly better variable naming for the transient `recursiveReadDir`.
2017-09-26 10:53:30 -07:00

22 lines
859 B
TypeScript

// Type definitions for recursive-readdir 2.2
// Project: https://github.com/jergason/recursive-readdir/
// Definitions by: Elisée Maurer <https://github.com/elisee>, Micah Zoltu <https://github.com/MicahZoltu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import * as fs from "fs";
declare namespace RecursiveReaddir {
type IgnoreFunction = (file: string, stats: fs.Stats) => boolean;
type Ignores = ReadonlyArray<string|IgnoreFunction>;
type Callback = (error: Error, files: string[]) => void;
interface readDir {
(path: string, ignores?: Ignores): Promise<string[]>;
(path: string, callback: Callback): void;
(path: string, ignores: Ignores, callback: Callback): void;
}
}
declare var recursiveReadDir: RecursiveReaddir.readDir;
export = recursiveReadDir;