* Don't get apparent type of contextual type for spread expressions * Add regression test
36 lines
599 B
Plaintext
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
|
|
}
|
|
|