then / is-promise

Test whether an object looks like a promises-a+ promise
MIT License
282 stars 32 forks source link

Wrong type guard! #39

Closed rkatic closed 4 years ago

rkatic commented 4 years ago

The guard should use PromiseLike<T>, not Promise<T>.

If a thenable can be considered a Promise/A+ promise ("if it looks like a duck, it is a duck"), it certainly does not means it's also a ES Promise (which also has catch and finally). Therefore the PromiseLike in TypeScript.