Title: Excess properties in tagged union not checked if type is optional and literal · Issue #31655 · microsoft/TypeScript · GitHub
Open Graph Title: Excess properties in tagged union not checked if type is optional and literal · Issue #31655 · microsoft/TypeScript
X Title: Excess properties in tagged union not checked if type is optional and literal · Issue #31655 · microsoft/TypeScript
Description: TypeScript Version: 3.4.1, 3.5.1 Search Terms: tagged union optional literal excess properties props Code type Button = { tag: 'button'; type?: 'submit'; }; type Anchor = { tag: 'a'; type?: string; href: string }; type Union = Button | A...
Open Graph Description: TypeScript Version: 3.4.1, 3.5.1 Search Terms: tagged union optional literal excess properties props Code type Button = { tag: 'button'; type?: 'submit'; }; type Anchor = { tag: 'a'; type?: string;...
X Description: TypeScript Version: 3.4.1, 3.5.1 Search Terms: tagged union optional literal excess properties props Code type Button = { tag: 'button'; type?: 'submit'; }; type Anchor = { tag: ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/31655
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Excess properties in tagged union not checked if type is optional and literal","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 3.4.1, 3.5.1\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** tagged union optional literal excess properties props\r\n\r\n**Code**\r\n\r\n```ts\r\ntype Button = { tag: 'button'; type?: 'submit'; };\r\ntype Anchor = { tag: 'a'; type?: string; href: string };\r\n\r\ntype Union = Button | Anchor;\r\nconst obj: Union = {\r\n tag: 'button',\r\n type: 'submit',\r\n\r\n // no error, bad! :-(\r\n href: 'foo',\r\n // error, good! :-)\r\n href2: 'foo',\r\n};\r\n```\r\n\r\nIf I replace `Button` with:\r\n\r\n``` ts\r\ntype Button = { tag: 'button'; type?: string };\r\n```\r\n\r\nThat is, if I replace the optional string literal with an optional string, then it works as expected (I get an error for the excess prop `href`), suggesting this is down to the fact that we're using string literals?","author":{"url":"https://github.com/OliverJAsh","@type":"Person","name":"OliverJAsh"},"datePublished":"2019-05-29T18:10:20Z","url":"https://github.com/microsoft/TypeScript/issues/31655"}
| 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:84ff705a-9eaa-d2a9-1220-4d1e0bcc5805 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 971A:2054A4:36FCDF:469407:6B04F534 |
| html-safe-nonce | 284ba6afdbcd79ecc4d8d8bec4156198a87c19a3182746ee39af1c2df17ef2aa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzFBOjIwNTRBNDozNkZDREY6NDY5NDA3OjZCMDRGNTM0IiwidmlzaXRvcl9pZCI6IjgyOTE3NzI2MTI1Nzc5MTYyMTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5ed8afa10abad53e849386e5e6afbacd5da36dceaa46741feedfac208da7fd99 |
| hovercard-subject-tag | issue:449949199 |
| 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/31655/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3ff6e4454f8e297b0f854fd7090a854a8ccc0b7d97a235536483ea057bae7035/microsoft/TypeScript/issues/31655 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3ff6e4454f8e297b0f854fd7090a854a8ccc0b7d97a235536483ea057bae7035/microsoft/TypeScript/issues/31655 |
| og:image:alt | TypeScript Version: 3.4.1, 3.5.1 Search Terms: tagged union optional literal excess properties props Code type Button = { tag: 'button'; type?: 'submit'; }; type Anchor = { tag: 'a'; type?: string;... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | OliverJAsh |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2c3971d6ab4be607cf9a26ac26ef0a7bfce380ec2ba14642e64028ad07a492b9 |
| 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 | b3f1d45dee14b3f87c64e9017a9c08d011561786 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width