TypeScript/tests/cases/conformance/types/spread/spreadOverwritesProperty.ts
Nathan Shively-Sanders a772c26a71
Error when property is specified more than once via a spread (#36727)
* add tests but not baselines or fixes

* Update original change

Still probably wrong; probably doesn't even compile beacuse I'm just
typing on my laptop.

* fix error code ok

* notes to self

* Error: property is specified more than once via spread

* make jsx tests stricter

* update semicolon error message

* use ?. because it is great

* use maybeTypeOfKind in new code

* restore jsx error

* add tests
2020-02-11 10:23:15 -08:00

14 lines
383 B
TypeScript

// without strict null checks, none of these should be an error
declare var ab: { a: number, b: number };
declare var abq: { a: number, b?: number };
var unused1 = { b: 1, ...ab }
var unused2 = { ...ab, ...ab }
var unused3 = { b: 1, ...abq }
function g(obj: { x: number | undefined }) {
return { x: 1, ...obj };
}
function h(obj: { x: number }) {
return { x: 1, ...obj };
}