{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/12292","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/12292/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/12292/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/12292/events","html_url":"https://github.com/Microsoft/TypeScript/issues/12292","id":189600620,"number":12292,"title":"Cannot `await` on interfaces extending `Promise<any>` in TypeScript 2.1 RC","user":{"login":"thomasboyt","id":579628,"avatar_url":"https://avatars.githubusercontent.com/u/579628?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasboyt","html_url":"https://github.com/thomasboyt","followers_url":"https://api.github.com/users/thomasboyt/followers","following_url":"https://api.github.com/users/thomasboyt/following{/other_user}","gists_url":"https://api.github.com/users/thomasboyt/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasboyt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasboyt/subscriptions","organizations_url":"https://api.github.com/users/thomasboyt/orgs","repos_url":"https://api.github.com/users/thomasboyt/repos","events_url":"https://api.github.com/users/thomasboyt/events{/privacy}","received_events_url":"https://api.github.com/users/thomasboyt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-16T06:03:50Z","updated_at":"2016-12-07T01:10:09Z","closed_at":null,"body":"For context: I ran into this bug using [Knex](http://knexjs.org/) and its type definition in TypeScript 2.1 RC. Knex's type definitions use [an extended `Promise` interface](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/knex/knex.d.ts#L321) for every value returned from a query, to allow for further chaining. Unfortunately, it looks like async/await in TypeScript does not support this.\r\n\r\nI 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.\r\n\r\n**TypeScript Version:**  `typescript@rc` (2.1.1)\r\n\r\n**Code**\r\n\r\n`main.ts`:\r\n\r\n```ts\r\ninterface PromiseExtender extends Promise<any> {\r\n}\r\n\r\nfunction getPromiseExtender(): PromiseExtender {\r\n  return new Promise((resolve, reject) => {});\r\n}\r\n\r\nasync function main() {\r\n  await getPromiseExtender();  // error: Operand for 'await' does not have a valid callable 'then' member.\r\n}\r\n```\r\n\r\n`tsconfig.json`:\r\n\r\n```json\r\n{\r\n  \"compilerOptions\": {\r\n    \"target\": \"es5\",\r\n    \"lib\": [\"dom\", \"es6\", \"es2015.promise\", \"es2015.iterable\", \"scripthost\"],\r\n    \"module\": \"commonjs\",\r\n    \"sourceMap\": true,\r\n    \"strictNullChecks\": true,\r\n    \"noImplicitAny\": true\r\n  }\r\n}\r\n```\r\n\r\nRunnable test case: https://github.com/thomasboyt/typescript-await-promise-bug-test-case\r\n\r\n**Expected behavior:** TypeScript allows `await`ing interfaces extending `Promise<any>`.\r\n\r\n**Actual behavior:** TypeScript displays the error `Operand for 'await' does not have a valid callable 'then' member.`.\r\n\r\nMy 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 :)\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/265325047","html_url":"https://github.com/Microsoft/TypeScript/issues/12292#issuecomment-265325047","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/12292","id":265325047,"user":{"login":"itaysabato","id":2768658,"avatar_url":"https://avatars.githubusercontent.com/u/2768658?v=3","gravatar_id":"","url":"https://api.github.com/users/itaysabato","html_url":"https://github.com/itaysabato","followers_url":"https://api.github.com/users/itaysabato/followers","following_url":"https://api.github.com/users/itaysabato/following{/other_user}","gists_url":"https://api.github.com/users/itaysabato/gists{/gist_id}","starred_url":"https://api.github.com/users/itaysabato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itaysabato/subscriptions","organizations_url":"https://api.github.com/users/itaysabato/orgs","repos_url":"https://api.github.com/users/itaysabato/repos","events_url":"https://api.github.com/users/itaysabato/events{/privacy}","received_events_url":"https://api.github.com/users/itaysabato/received_events","type":"User","site_admin":false},"created_at":"2016-12-07T01:10:09Z","updated_at":"2016-12-07T01:10:09Z","body":"Same deal with [superagent](https://github.com/itaysabato/DefinitelyTyped/blob/36d40a63a05b5cb3413737fbdf7c9a2a26f211fd/superagent/superagent.d.ts#L84).\r\nIt doesn't seem like it matters what is used as the generic parameter..."}}
{"actor":{"display_login":"itaysabato"}}