TypeScript/tests/baselines/reference/spreadExpressionContextualType.types
Anders Hejlsberg 42f0cf6ffc
Don't eagerly get apparent type of spread expression contextual type (#44002)
* Don't get apparent type of contextual type for spread expressions

* Add regression test
2021-05-07 15:44:17 -07:00

36 lines
599 B
Plaintext

=== tests/cases/compiler/spreadExpressionContextualType.ts ===
// Repro from #43966
interface Orange {
name: string;
>name : string
}
interface Apple {
name: string;
>name : string
}
function test<T extends Apple | Orange>(item: T): T {
>test : <T extends Orange | Apple>(item: T) => T
>item : T
return { ...item };
>{ ...item } : T
>item : T
}
function test2<T extends Apple | Orange>(item: T): T {
>test2 : <T extends Orange | Apple>(item: T) => T
>item : T
const x = { ...item };
>x : T
>{ ...item } : T
>item : T
return x;
>x : T
}