TypeScript/tests/baselines/reference/spreadDuplicate.errors.txt
Anders Hejlsberg 61ccc49a7b
Fix check for overwritten properties in object spreads (#44696)
* Fix check for overwritten properties in object spreads

* Accept new baselines

* Add tests

* Accept new baselines
2021-06-22 14:39:33 -07:00

30 lines
1.5 KiB
Plaintext

tests/cases/conformance/types/spread/spreadDuplicate.ts(10,12): error TS2783: 'a' is specified more than once, so this usage will be overwritten.
tests/cases/conformance/types/spread/spreadDuplicate.ts(12,12): error TS2783: 'a' is specified more than once, so this usage will be overwritten.
==== tests/cases/conformance/types/spread/spreadDuplicate.ts (2 errors) ====
// Repro from #44438
declare let a: { a: string };
declare let b: { a?: string };
declare let c: { a: string | undefined };
declare let d: { a?: string | undefined };
declare let t: boolean;
let a1 = { a: 123, ...a }; // string (Error)
~~~~~~
!!! error TS2783: 'a' is specified more than once, so this usage will be overwritten.
!!! related TS2785 tests/cases/conformance/types/spread/spreadDuplicate.ts:10:20: This spread always overwrites this property.
let b1 = { a: 123, ...b }; // string | number
let c1 = { a: 123, ...c }; // string | undefined (Error)
~~~~~~
!!! error TS2783: 'a' is specified more than once, so this usage will be overwritten.
!!! related TS2785 tests/cases/conformance/types/spread/spreadDuplicate.ts:12:20: This spread always overwrites this property.
let d1 = { a: 123, ...d }; // string | number
let a2 = { a: 123, ...(t ? a : {}) }; // string | number
let b2 = { a: 123, ...(t ? b : {}) }; // string | number
let c2 = { a: 123, ...(t ? c : {}) }; // string | number
let d2 = { a: 123, ...(t ? d : {}) }; // string | number