diff --git a/types/file-exists/file-exists-tests.ts b/types/file-exists/file-exists-tests.ts new file mode 100644 index 0000000000..3293dc795f --- /dev/null +++ b/types/file-exists/file-exists-tests.ts @@ -0,0 +1,15 @@ +import fileExists = require('file-exists'); + +fileExists('/index.html', (err, exists) => { + err; // $ExpectType Error | null + exists; // $ExpectType boolean +}); + +fileExists('/index.html', {root: ''}, (err, exists) => { + err; // $ExpectType Error | null + exists; // $ExpectType boolean +}); + +// $ExpectType boolean +fileExists.sync('/index.html'); +fileExists.sync('/index.html', {root: ''}); diff --git a/types/file-exists/index.d.ts b/types/file-exists/index.d.ts new file mode 100644 index 0000000000..f2c17e40bf --- /dev/null +++ b/types/file-exists/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for file-exists 4.0 +// Project: https://github.com/scottcorgan/file-exists +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = fileExists; + +declare function fileExists(filepath: string, callback?: (err: Error | null, exists: boolean) => void): void; +declare function fileExists(filepath: string, options?: fileExists.Options, callback?: (err: Error | null, exists: boolean) => void): void; + +declare namespace fileExists { + function sync(filepath: string, options?: Options): boolean; + + interface Options { + root?: string; + } +} diff --git a/types/file-exists/tsconfig.json b/types/file-exists/tsconfig.json new file mode 100644 index 0000000000..4d4cd410b7 --- /dev/null +++ b/types/file-exists/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "file-exists-tests.ts" + ] +} diff --git a/types/file-exists/tslint.json b/types/file-exists/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/file-exists/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }