8000 Generic with extends and return will fail compilation · Issue #17794 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
Generic with extends and return will fail compilation #17794
Closed
@jsgoupil

Description

@jsgoupil

TypeScript Version: 2.4.2

class A {

}

export class B {
    public method<T extends A>(val: T): Promise<T> {
        return new Promise(resolver => {
            resolver(new A());
        });
    }
}

It fails with this
Argument of type 'A' is not assignable to parameter of type 'T | PromiseLike'.
Type 'A' is not assignable to type 'PromiseLike'.
Property 'then' is missing in type 'A'.

This code compiled just fine in 2.3

It looks similar to this old bug which compiled fine with 2.3, but fails with 2.4
#13993

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0