Closed
Description
We are having problems with TypeScript 3.9 upgrade for our repositories and the spread operator and "&&" with any types. TypeScript compiler says the value will be always overridden even though an any type isn't 100% always null/undefined.
TypeScript Version: 3.9.5
Search Terms:
- specified more than once, so this usage will be overwritten.
- any type and spread operator
Code
Doesn't work
let isTreeHeader : any = null!;
function foo(){
return {
display: "block",
...(isTreeHeader && {
display: "flex",
})
}
}
foo()
Works
let isTreeHeader : number = null!;
function foo(){
return {
display: "block",
...(isTreeHeader && {
display: "flex",
})
}
}
foo()
Expected behavior:
any
type can be undefined or can have a non nullable value so we shouldn't get an error with the spread operator
Actual behavior:
'display' is specified more than once, so this usage will be overwritten.ts(2783)
Related Issues: