mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
15 lines
259 B
TypeScript
15 lines
259 B
TypeScript
import isPromise = require("is-promise");
|
|
|
|
isPromise({ then() {} });
|
|
isPromise(null);
|
|
isPromise({});
|
|
isPromise({then: true});
|
|
|
|
function f(x: number | PromiseLike<number>) {
|
|
if (isPromise(x)) {
|
|
x.then;
|
|
} else {
|
|
x.toExponential;
|
|
}
|
|
}
|