Title: Enum members aren't subtype reduced in unions · Issue #35867 · microsoft/TypeScript · GitHub
Open Graph Title: Enum members aren't subtype reduced in unions · Issue #35867 · microsoft/TypeScript
X Title: Enum members aren't subtype reduced in unions · Issue #35867 · microsoft/TypeScript
Description: enum E { A, B, C, } function f(x: E | undefined) { return x ?? E.C; } Expected f to have type E, but instead it has type E | E.C Playground Doesn't have anything to do with ?? - can reproduce it with ||. enum E { A = 1, B, C, } function ...
Open Graph Description: enum E { A, B, C, } function f(x: E | undefined) { return x ?? E.C; } Expected f to have type E, but instead it has type E | E.C Playground Doesn't have anything to do with ?? - can reproduce it wi...
X Description: enum E { A, B, C, } function f(x: E | undefined) { return x ?? E.C; } Expected f to have type E, but instead it has type E | E.C Playground Doesn't have anything to do with ?? - can reproduce i...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/35867
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Enum members aren't subtype reduced in unions","articleBody":"```ts repro\r\nenum E {\r\n A,\r\n B,\r\n C,\r\n}\r\n\r\nfunction f(x: E | undefined) {\r\n return x ?? E.C;\r\n}\r\n```\r\n\r\nExpected `f` to have type `E`, but instead it has type `E | E.C`\r\n\r\n[Playground](http://www.typescriptlang.org/play/index.html?ts=3.8.0-dev.20191224&ssl=1&ssc=1&pln=9&pc=2#code/KYOwrgtgBAolDeAoKKoEEA0zUCEuqgGEsBfRRAMzBAGMAXASwHsQoKAKADwC5YoAfKNQAmwCgxDBhASgTYUAJ2B0wC1pygB+TbAB0hANyISQA)\r\n\r\nDoesn't have anything to do with `??` - can reproduce it with `||`.\r\n\r\n```ts\r\nenum E {\r\n A = 1,\r\n B,\r\n C,\r\n}\r\n\r\nfunction f(x: E | undefined) {\r\n return x || E.C;\r\n}\r\n```","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2019-12-27T04:50:00Z","url":"https://github.com/microsoft/TypeScript/issues/35867"}
| 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:ce46fdbf-8c2b-2afe-7895-083804e29cac |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 91CE:317608:355F0B9:439BE32:6B01DCD5 |
| html-safe-nonce | 308d6744b312b2e52b23f0e4c852c425b8281ee04580f4c675aab77905688b0a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MUNFOjMxNzYwODozNTVGMEI5OjQzOUJFMzI6NkIwMURDRDUiLCJ2aXNpdG9yX2lkIjoiNjkyODgwMDI2MDU3MTY1MTI4NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a6b47b220078774d1c0ffcefd856c5544e242b0fdba91cf4e060b3170303c7c3 |
| hovercard-subject-tag | issue:542743083 |
| 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/35867/issue_layout |
| twitter:image | https://opengraph.githubassets.com/44367445806c226ddbb53a0af8a166ab41acb37d9d5fbb3859f7908ab4f26022/microsoft/TypeScript/issues/35867 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/44367445806c226ddbb53a0af8a166ab41acb37d9d5fbb3859f7908ab4f26022/microsoft/TypeScript/issues/35867 |
| og:image:alt | enum E { A, B, C, } function f(x: E | undefined) { return x ?? E.C; } Expected f to have type E, but instead it has type E | E.C Playground Doesn't have anything to do with ?? - can reproduce it wi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DanielRosenwasser |
| 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