Title: Unexpected exhaustive check result for switch statement · Issue #29559 · microsoft/TypeScript · GitHub
Open Graph Title: Unexpected exhaustive check result for switch statement · Issue #29559 · microsoft/TypeScript
X Title: Unexpected exhaustive check result for switch statement · Issue #29559 · microsoft/TypeScript
Description: TypeScript Version: typescript@3.3.0-dev.20190124 Search Terms: switch Code const assertUnreachable = (x: never): void => {} const f = (x: 'a' | 'b') => { switch (x) { case 'a': { } break; case 'a': { } break; } }; const g = (x: { t1: 'a...
Open Graph Description: TypeScript Version: typescript@3.3.0-dev.20190124 Search Terms: switch Code const assertUnreachable = (x: never): void => {} const f = (x: 'a' | 'b') => { switch (x) { case 'a': { } break; case 'a'...
X Description: TypeScript Version: typescript@3.3.0-dev.20190124 Search Terms: switch Code const assertUnreachable = (x: never): void => {} const f = (x: 'a' | 'b') => { switch (x) { case ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/29559
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unexpected exhaustive check result for switch statement","articleBody":"\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** typescript@3.3.0-dev.20190124\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** switch\r\n\r\n**Code**\r\n\r\n```typescript\r\nconst assertUnreachable = (x: never): void => {}\r\n\r\nconst f = (x: 'a' | 'b') => {\r\n switch (x) {\r\n case 'a':\r\n {\r\n }\r\n break;\r\n\r\n case 'a':\r\n {\r\n }\r\n break;\r\n }\r\n};\r\n\r\nconst g = (x: { t1: 'a'; t2: 'a1' | 'a2' } | { t1: 'b'; t2: 'b1' | 'b2' }) => {\r\n switch (x.t1) {\r\n case 'a':\r\n {\r\n switch (x.t2) {\r\n case 'a1':\r\n {\r\n }\r\n break;\r\n\r\n case 'a2':\r\n {\r\n }\r\n break;\r\n\r\n default: {\r\n assertUnreachable(x.t2);\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n};\r\n```\r\n**Expected behavior:**\r\n\r\nFunction `f` **should not** pass the typecheck at the second `case` block.\r\nFunction `g` **should** pass the typecheck at `assertUnreachable`.\r\n\r\n**Actual behavior:**\r\n\r\nFunction `f` **passes** the typecheck at the second `case` block.\r\nFunction `g` **doesn't pass** the typecheck at `assertUnreachable`.\r\n\r\nNote that if we put `assertUnreachable` in function `f`, it will work. So this seems to be only happening for the nested switch.\r\n","author":{"url":"https://github.com/lriuui0x0","@type":"Person","name":"lriuui0x0"},"datePublished":"2019-01-24T12:25:44Z","url":"https://github.com/microsoft/TypeScript/issues/29559"}
| 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:faf4a0ec-4d58-a1e5-a42a-52800620eaff |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A268:3C5464:1BDF26:266D37:6B04B4B0 |
| html-safe-nonce | 9f73ec857af627cda794cf793d7f99b22ac4323d26ab1686066cd63a0b914889 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjY4OjNDNTQ2NDoxQkRGMjY6MjY2RDM3OjZCMDRCNEIwIiwidmlzaXRvcl9pZCI6IjYyMjg5ODk0NDMzOTE2NjUzMjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 53ce13b0a7b56a1b0c1fe2f182c11a06a7fe42efd0c26c9b56d322f7cba4125b |
| hovercard-subject-tag | issue:402683827 |
| 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/29559/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7ed0b1ed9354cc327f688655a0fd96288a2fde5baf956ac4198c8ae056372b6a/microsoft/TypeScript/issues/29559 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7ed0b1ed9354cc327f688655a0fd96288a2fde5baf956ac4198c8ae056372b6a/microsoft/TypeScript/issues/29559 |
| og:image:alt | TypeScript Version: typescript@3.3.0-dev.20190124 Search Terms: switch Code const assertUnreachable = (x: never): void => {} const f = (x: 'a' | 'b') => { switch (x) { case 'a': { } break; case 'a'... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lriuui0x0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 378bd702ac792b3550e484ad39d9a898fcd25bb52ba6962b0c9cc457c1ea71c7 |
| 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 | b032e77f1ea437ede6c115446a0a467709b468e7 |
| 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