mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
Added the 'is-promise' library.
This commit is contained in:
8
is-promise/index.d.ts
vendored
Normal file
8
is-promise/index.d.ts
vendored
Normal 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
is-promise/is-promise-tests.ts
Normal file
15
is-promise/is-promise-tests.ts
Normal 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
19
is-promise/tsconfig.json
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user