[file-exists] add typings (#18926)

This commit is contained in:
Dimitri Benin
2017-08-14 19:05:48 +02:00
committed by Mohamed Hegazy
parent f18efced61
commit 74cfcd8638
4 changed files with 55 additions and 0 deletions

View File

@@ -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: ''});

17
types/file-exists/index.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
// Type definitions for file-exists 4.0
// Project: https://github.com/scottcorgan/file-exists
// Definitions by: BendingBender <https://github.com/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;
}
}

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }