Title: Intersection type operator doesn't discriminate Union Types · Issue #13203 · microsoft/TypeScript · GitHub
Open Graph Title: Intersection type operator doesn't discriminate Union Types · Issue #13203 · microsoft/TypeScript
X Title: Intersection type operator doesn't discriminate Union Types · Issue #13203 · microsoft/TypeScript
Description: type A = {tag: 'a', a: 1} | {tag: 'b', b: 1} type B = A & {tag: 'b'} declare var b : B let z = b.b // Error: Property 'b' does not exist on type 'B' Expected behavior: b (type B) only possible value for tag property is 'b', so it must be...
Open Graph Description: type A = {tag: 'a', a: 1} | {tag: 'b', b: 1} type B = A & {tag: 'b'} declare var b : B let z = b.b // Error: Property 'b' does not exist on type 'B' Expected behavior: b (type B) only possible valu...
X Description: type A = {tag: 'a', a: 1} | {tag: 'b', b: 1} type B = A & {tag: 'b'} declare var b : B let z = b.b // Error: Property 'b' does not exist on type 'B' Expe...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/13203
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Intersection type operator doesn't discriminate Union Types","articleBody":"```ts\r\ntype A = {tag: 'a', a: 1} | {tag: 'b', b: 1}\r\ntype B = A & {tag: 'b'}\r\n\r\ndeclare var b : B\r\nlet z = b.b // Error: Property 'b' does not exist on type 'B'\r\n```\r\n\r\n**Expected behavior:** `b` (type `B`) only possible value for `tag` property is` 'b'`, so it must be discriminated to `{tag : 'b' , 'b' : 1}` without needing to enclose it in a `if(b.tag == 'b')` type guard\r\n**Actual behavior:** `b` (type `B`) is not discriminated, needs type guards just like plain `A`\r\n**TypeScript Version:** 2.0.6\r\n\r\n","author":{"url":"https://github.com/nahuel","@type":"Person","name":"nahuel"},"datePublished":"2016-12-28T20:14:47Z","url":"https://github.com/microsoft/TypeScript/issues/13203"}
| 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:9ffb32ae-db83-9049-79b7-c3f37f884fed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C0C6:2F12FE:1DA27F:2768D8:6B04CD4A |
| html-safe-nonce | 1c05806cef01e04f016c9d35d1a138c40f7ac337c6e0fb6c20c0c77a0430832b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEM2OjJGMTJGRToxREEyN0Y6Mjc2OEQ4OjZCMDRDRDRBIiwidmlzaXRvcl9pZCI6IjU3NDA5MTc0ODE2NTczODgzNjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b1c10f070752b165491adbd1976a394c72eec07499d729dff25714202fb538eb |
| hovercard-subject-tag | issue:197910001 |
| 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/13203/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d477598c9deae9c202fedbc6c8b0e1ba22e626fa33a2e3aee92afabb1b594289/microsoft/TypeScript/issues/13203 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d477598c9deae9c202fedbc6c8b0e1ba22e626fa33a2e3aee92afabb1b594289/microsoft/TypeScript/issues/13203 |
| og:image:alt | type A = {tag: 'a', a: 1} | {tag: 'b', b: 1} type B = A & {tag: 'b'} declare var b : B let z = b.b // Error: Property 'b' does not exist on type 'B' Expected behavior: b (type B) only possible valu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nahuel |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27ed421e5c2dac040a37529b5b9191edcc4a3de70521471e81fb4b4d9dc2aa7d |
| 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 | 63dc19014c621c67306d7899c04c78dcd0d95803 |
| 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