Closed
Description
async function foo<T>(x: T): Promise<T> {
let yaddable = await getXOrYadda(x);
return yaddable;
}
interface Yadda {
stuff: string,
things: string,
}
declare function getXOrYadda<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'.