Merge pull request #10688 from DanielRosenwasser/is-promise

Added the 'is-promise' library.
This commit is contained in:
Paul van Brenk
2016-08-19 11:44:30 -07:00
committed by GitHub
3 changed files with 42 additions and 0 deletions
+8
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>;
+15
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
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
}
}