Title: Using && with spread operator causes "overridden" error if one of the types is "any" · Issue #39113 · microsoft/TypeScript · GitHub
Open Graph Title: Using && with spread operator causes "overridden" error if one of the types is "any" · Issue #39113 · microsoft/TypeScript
X Title: Using && with spread operator causes "overridden" error if one of the types is "any" · Issue #39113 · microsoft/TypeScript
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/undefine...
Open Graph 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 ...
X 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 overridd...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/39113
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using && with spread operator causes \"overridden\" error if one of the types is \"any\"","articleBody":"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.\r\n\r\n**TypeScript Version:** 3.9.5\r\n**Search Terms:**\r\n- specified more than once, so this usage will be overwritten.\r\n- any type and spread operator\r\n\r\n**Code**\r\n\r\nDoesn't work\r\n```ts\r\nlet isTreeHeader : any = null!;\r\nfunction foo(){\r\n return {\r\n display: \"block\",\r\n ...(isTreeHeader && {\r\n display: \"flex\",\r\n })\r\n }\r\n}\r\nfoo()\r\n```\r\n\r\nWorks\r\n```ts\r\nlet isTreeHeader : number = null!;\r\nfunction foo(){\r\n return {\r\n display: \"block\",\r\n ...(isTreeHeader && {\r\n display: \"flex\",\r\n })\r\n }\r\n}\r\nfoo()\r\n```\r\n\r\n**Expected behavior:**\r\n\r\n`any` type can be undefined or can have a non nullable value so we shouldn't get an error with the spread operator\r\n\r\n**Actual behavior:**\r\n\r\n'display' is specified more than once, so this usage will be overwritten.ts(2783)\r\n\r\n**Playground Link:** \r\nhttps://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=2&pc=22#code/DYUwLgBAlgzgKgJxCAEiAhgExAiAuCdAOwE8IBeCIgV2GAEIBuAKADNqiBjMKAeyIitevABQBKAN7MISMNQQCpETLAAOwdCQIAiAEbBenANbaANNIB0VkbETI0WHBABkziEpUx1mna1AAPM2kAXzEQ5mC2YXEgA\r\n\r\n**Related Issues:** ","author":{"url":"https://github.com/mastrzyz","@type":"Person","name":"mastrzyz"},"datePublished":"2020-06-17T17:06:41Z","url":"https://github.com/microsoft/TypeScript/issues/39113"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9a8333c7-7879-c434-deb4-e3d373c43e69 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8BDE:A71F9:18F660E:1F79D40:6B017F57 |
| html-safe-nonce | 62aa6f3786f0fa58e4b4ee955564f649c5762a0533b6f0f793af3784c098ab16 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkRFOkE3MUY5OjE4RjY2MEU6MUY3OUQ0MDo2QjAxN0Y1NyIsInZpc2l0b3JfaWQiOiI0NTExNTAwNTc3OTg5MDMzODE1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 593f7993a38d97661752b6290c76e2fa8a0ca388ab6084d60c105264580a8333 |
| hovercard-subject-tag | issue:640605237 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/39113/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d09d080415747839f417f6697756934c88098c8a95e247545d7479b817fc0b3/microsoft/TypeScript/issues/39113 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d09d080415747839f417f6697756934c88098c8a95e247545d7479b817fc0b3/microsoft/TypeScript/issues/39113 |
| og:image:alt | 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mastrzyz |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width