Closed
Description
TypeScript Version: 3.7.x-dev.201xxxxx
Search Terms:
PromiseLike await
Code
const promiseA = new Promise(resolve => {
resolve(5);
})
async function main() {
const a = await 5; // typescript will give warning 80007
const b = await promiseA; // expected
const c = await ({} as PromiseLike<number>); // The cast to PromiseLike silences 80007
}
Expected behavior:
There should be warning on the line with const c. I found this while using chai-as-promised. "await expect(promise).to.eventually.be(arg)" was throwing UnhandledPromiseRejectionWarning. Chai.PromisedAssertion is a PromiseLike and not a Promise (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/chai-as-promised/index.d.ts#L105) and it's not safe to use with await. But the type system hid that from me.
Actual behavior:
No warning.
Playground Link:
Related Issues:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment