type A = {
a?: any
}
const a: A = {};
const b = { a: 'zzz', ...a, }; // 'a' is specified more than once, so this usage will be overwritten
'a' is specified more than once, so this usage will be overwritten.(2783)
input.ts(6, 24): This spread always overwrites this property.
TypeScript Version: 3.9.0-dev.20200328
Search Terms:
property-will-be-overwritten-by-spread
Code
Using string instead of any as the type of
aproperty in A works as expected.Expected behavior:
No error
Actual behavior:
Playground Link:
Using any errors - bug
https://www.typescriptlang.org/play/?ts=3.9.0-dev.20200328&ssl=6&ssc=32&pln=1&pc=1#code/C4TwDgpgBAglC8UDeAoK6oEMD8AuLAdiCgL4ooDGA9gQM7Bb5yJIkDclN9UARgsukz4A5AC9xwgDRQAdHMzT2QA
Using string no error - works as expected
https://www.typescriptlang.org/play/?ts=3.9.0-dev.20200328#code/C4TwDgpgBAglC8UDeAoK6oEMD8AuKAzsAE4CWAdgOYoC+KKAxgPblFb5yJI0DcjLbAEYJk6TPgDkALxkSANFAB0yzAt5A
Related Issues: #36779