Description
For context: I ran into this bug using Knex and its type definition in TypeScript 2.1 RC. Knex's type definitions use an extended Promise
interface for every value returned from a query, to allow for further chaining. Unfortunately, it looks like async/await in TypeScript does not support this.
I found several references to fixed issues and regressions in prior versions of TypeScript, but could not find an open issue for the current version. Apologies if this is a duplicate issue.
TypeScript Version: typescript@rc
(2.1.1)
Code
main.ts
:
interface PromiseExtender extends Promise<any> {
}
function getPromiseExtender(): PromiseExtender {
return new Promise((resolve, reject) => {});
}
async function main() {
await getPromiseExtender(); // error: Operand for 'await' does not have a valid callable 'then' member.
}
tsconfig.json
:
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "es6", "es2015.promise", "es2015.iterable", "scripthost"],
"module": "commonjs",
"sourceMap": true,
"strictNullChecks": true,
"noImplicitAny": true
}
}
Runnable test case: https://github.com/thomasboyt/typescript-await-promise-bug-test-case
Expected behavior: TypeScript allows await
ing interfaces extending Promise<any>
.
Actual behavior: TypeScript displays the error Operand for 'await' does not have a valid callable 'then' member.
.
My current workaround for this is to just await (promiseExtendingObject as any)
, so it's not the end of the world. Hopefully can be fixed before 2.1 is released, though :)