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'.
Here, you'll get an error like
Proposed
Either
or