Skip to content

TypeScript 2.1.4 - error compiling async/await with Promises typed as this #12910

Closed
@ryanwe

Description

@ryanwe

TypeScript Version: 2.1.4

Code

interface Bar extends Promise<void> {
    foo(): this;
    // also repros with `foo(): Bar;`
}

const buggy = async (param: Bar) => {
    await param.foo();
};

Expected behavior:
In TypeScript 2.0.3 this code will compile successfully.

Actual behavior:
In TypeScript 2.1.4 this code will not compile successfully and gives the error error TS1058: Operand for 'await' does not have a valid callable 'then' member.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions