Skip to content

Chained promises produce incorrect types #10977

Closed
@MaximBalaganskiy

Description

@MaximBalaganskiy

TypeScript Version: nightly (2.1.0-dev.20160918)

Code

class A {
    json(): Promise<any> {
        return Promise.resolve({});
    };
}

function test() {
    let p = Promise.resolve(new A());
    p.then(x => x.json()).then(x => x.b);
}

Expected behavior:
Compiled without errors

Actual behavior:
Compiled with an error

error TS2339: Property 'b' does not exist on type 'A'.

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