Closed
Description
TypeScript Version: 3.9.0-dev.20200328
Search Terms:
property-will-be-overwritten-by-spread
Code
type A = {
a?: any
}
const a: A = {};
const b = { a: 'zzz', ...a, }; // 'a' is specified more than once, so this usage will be overwritten
Using string instead of any as the type of a
property in A works as expected.
Expected behavior:
No error
Actual behavior:
'a' is specified more than once, so this usage will be overwritten.(2783)
input.ts(6, 24): This spread always overwrites this property.
Playground Link:
Using any errors - bug
Using string no error - works as expected
Related Issues: #36779