Skip to content

Unnecessary elaboration about not being assignable to type parameters #42849

Description

asyncfunctionfoo<T>(x: T): Promise<T>{letyaddable=awaitgetXOrYadda(x);returnyaddable;}interfaceYadda{stuff: string,things: string,}declarefunctiongetXOrYadda<T>(x: T): T|Yadda;

Here, you'll get an error like

Type 'T | Yadda' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'T | Yadda'.
Type 'Yadda' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'Yadda'.

Proposed

Either

Type 'T | Yadda' is not assignable to type 'T'.
Type 'Yadda' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'Yadda'.

or

Type 'T | Yadda' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'T | Yadda'.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions