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
letisTreeHeader : any=null!;functionfoo(){return{display: "block",
...(isTreeHeader&&{display: "flex",})}}foo()Works
letisTreeHeader : number=null!;functionfoo(){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)
Playground Link:
https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=2&pc=22#code/DYUwLgBAlgzgKgJxCAEiAhgExAiAuCdAOwE8IBeCIgV2GAEIBuAKADNqiBjMKAeyIitevABQBKAN7MISMNQQCpETLAAOwdCQIAiAEbBenANbaANNIB0VkbETI0WHBABkziEpUx1mna1AAPM2kAXzEQ5mC2YXEgA
Related Issues:
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:
Code
Doesn't work
Works
Expected behavior:
anytype can be undefined or can have a non nullable value so we shouldn't get an error with the spread operatorActual behavior:
'display' is specified more than once, so this usage will be overwritten.ts(2783)
Playground Link:
https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=2&pc=22#code/DYUwLgBAlgzgKgJxCAEiAhgExAiAuCdAOwE8IBeCIgV2GAEIBuAKADNqiBjMKAeyIitevABQBKAN7MISMNQQCpETLAAOwdCQIAiAEbBenANbaANNIB0VkbETI0WHBABkziEpUx1mna1AAPM2kAXzEQ5mC2YXEgA
Related Issues: