8000 Incorrect typecheck on generic Promise<T> with inheritance · Issue #15564 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
Incorrect typecheck on generic Promise<T> with inheritance #15564
Closed
@MichalLytek

Description

@MichalLytek

TypeScript Version: 2.3.2

Code

class A {
    a: number;
}

class Aplus extends A {
    plus = () => true;
}

function newAplusAsync(): Promise<Aplus> {
    return Promise.resolve(new A());
}

(async () => {
    const aplus = await newAplusAsync();
    console.log(aplus.plus());
})();

Expected behavior:
Compiler error: Type 'Promise<A>' is not assignable to type 'Promise<Aplus>'

Actual behavior:
Runtime error: aplus.plus is not a function​​

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0