-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeBugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
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:
caaldrid, gagarwal, KeijiBranshi, mastrzyz and konpikwastaken
Metadata
Metadata
Assignees
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeBugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue