Merge pull request #18719 from BendingBender/path-exists

[path-exists] add typings for v3, add strict null checks & linting
This commit is contained in:
Andrew Casey
2017-08-08 13:22:16 -07:00
committed by GitHub
8 changed files with 59 additions and 16 deletions

View File

@@ -1,13 +1,13 @@
// Type definitions for path-exists 1.0.0
// Type definitions for path-exists 3.0
// Project: https://github.com/sindresorhus/path-exists
// Definitions by: Shogo Iwano <https://github.com/shiwano>
// BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface PathExists {
(path: string, callback: (error: Error, exists: boolean) => void): void;
sync(path: string): boolean;
}
declare var pathExists: PathExists;
export = pathExists;
declare function pathExists(path: string): Promise<boolean>;
declare namespace pathExists {
function sync(path: string): boolean;
}

View File

@@ -1,7 +1,6 @@
import pathExists = require("path-exists");
pathExists("test/path-exists.d.ts", (error, exists) => {
console.log(exists);
pathExists('foo.js').then(exists => {
const bool: boolean = exists;
});
console.log(pathExists.sync("test/__path-exists.d.ts"));
const bool: boolean = pathExists.sync("test/__path-exists.d.ts");

View File

@@ -2,12 +2,11 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -20,4 +19,4 @@
"index.d.ts",
"path-exists-tests.ts"
]
}
}

View File

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

12
types/path-exists/v1/index.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
// Type definitions for path-exists 1.0
// Project: https://github.com/sindresorhus/path-exists
// Definitions by: Shogo Iwano <https://github.com/shiwano>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface PathExists {
(path: string, callback: (error: Error, exists: boolean) => void): void;
sync(path: string): boolean;
}
declare const pathExists: PathExists;
export = pathExists;

View File

@@ -0,0 +1,6 @@
import pathExists = require("path-exists");
pathExists("test/path-exists.d.ts", (error, exists) => {
const bool: boolean = exists;
});
const bool: boolean = pathExists.sync("test/__path-exists.d.ts");

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"path-exists": ["path-exists/v1"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"path-exists-tests.ts"
]
}

View File

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