Added the 'is-promise' library.

This commit is contained in:
Daniel Rosenwasser
2016-08-18 00:46:55 -07:00
parent 46de69ea63
commit 70380f3fde
3 changed files with 42 additions and 0 deletions

8
is-promise/index.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
// Type definitions for is-promise
// Project: https://github.com/then/is-promise
// Definitions by: Daniel Rosenwasser <https://github.com/DanielRosenwasser>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = isPromise;
declare function isPromise(obj: any): obj is PromiseLike<any>;

View File

@@ -0,0 +1,15 @@
import isPromise = require("./");
isPromise({ then() { }});
isPromise(null);
isPromise({ });
isPromise({then: true});
function f(x: number | PromiseLike<number>) {
if (isPromise(x)) {
x.then;
}
else {
x.toExponential;
}
}

19
is-promise/tsconfig.json Normal file
View File

@@ -0,0 +1,19 @@
{
"files": [
"index.d.ts",
"is-promise-tests.ts"
],
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
}