Breaking Changes
-
Use
PromiseLike
instead ofPromise
in TypeScript (#40)This is only a breaking change for TypeScript users.
In the following code:
function foo(x: PromiseLike<string> | string) { if (isPromise(x)) { return x; } else { return Promise.resolve(x); } }
TypeScript would previously have incorrectly inferred
foo
as returningPromise
string>when in fact it returns
PromiseLikestring>
. The latest version fixes this. If you instead had the following code, it should work exactly the same as before:function foo(x: Promise<string> | string) { if (isPromise(x)) { return x; } else { return Promise.resolve(x); } }
This update is to reflect the fact that
is-promise
does "duck" typing, rather than aninstanceof
check.