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
This commit is contained in:
Anders Hejlsberg
2021-05-07 15:44:17 -07:00
committed by GitHub
parent cb9cd898d1
commit 42f0cf6ffc
5 changed files with 157 additions and 1 deletions
@@ -0,0 +1,21 @@
// @strict: true
// @declaration: true
// Repro from #43966
interface Orange {
name: string;
}
interface Apple {
name: string;
}
function test<T extends Apple | Orange>(item: T): T {
return { ...item };
}
function test2<T extends Apple | Orange>(item: T): T {
const x = { ...item };
return x;
}