Title: Erroneous type narrowing in finally · Issue #18478 · microsoft/TypeScript · GitHub
Open Graph Title: Erroneous type narrowing in finally · Issue #18478 · microsoft/TypeScript
X Title: Erroneous type narrowing in finally · Issue #18478 · microsoft/TypeScript
Description: TypeScript Version: Version 2.6.0-dev.20170914 Code function test() { type YesNo = ('No' | 'Yes'); let answer: YesNo = 'No'; // Bug disappears after adding 'as YesNo'. try { answer = 'Yes'; return; // Bug disappears after removing the re...
Open Graph Description: TypeScript Version: Version 2.6.0-dev.20170914 Code function test() { type YesNo = ('No' | 'Yes'); let answer: YesNo = 'No'; // Bug disappears after adding 'as YesNo'. try { answer = 'Yes'; return;...
X Description: TypeScript Version: Version 2.6.0-dev.20170914 Code function test() { type YesNo = ('No' | 'Yes'); let answer: YesNo = 'No'; // Bug disappears after adding 'as YesNo'...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/18478
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Erroneous type narrowing in finally","articleBody":"\r\n**TypeScript Version:** Version 2.6.0-dev.20170914\r\n\r\n**Code**\r\n\r\n```ts\r\nfunction test() {\r\n type YesNo = ('No' | 'Yes');\r\n let answer: YesNo = 'No'; // Bug disappears after adding 'as YesNo'.\r\n try {\r\n answer = 'Yes';\r\n return; // Bug disappears after removing the return.\r\n } finally {\r\n if (answer === 'Yes') { // Bug: Operator === cannot be applied to types 'No' and 'Yes'\r\n } else if (answer === 'No') {\r\n }\r\n }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nNo compilation errors.\r\n\r\n**Actual behavior:**\r\nCompilation error:\r\nbug.ts(8,13): error TS2365: Operator '===' cannot be applied to types '\"No\"' and '\"Yes\"'.\r\n\r\n**Note:**\r\nThis bug is similar to \"Erroneous control flow type narrowing in loops\": https://github.com/Microsoft/TypeScript/issues/15835","author":{"url":"https://github.com/Zbyl","@type":"Person","name":"Zbyl"},"datePublished":"2017-09-14T20:00:02Z","url":"https://github.com/microsoft/TypeScript/issues/18478"}
| 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:048c50b9-8655-93bd-d2ad-f8cdf3f7cb06 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EDEC:399E4B:E42EFB:12FDF39:6B01026D |
| html-safe-nonce | 94f9292b1577cb6730a2aa0e23d8b34f7bf03672b1054779976ccf2ac9a98d0f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFREVDOjM5OUU0QjpFNDJFRkI6MTJGREYzOTo2QjAxMDI2RCIsInZpc2l0b3JfaWQiOiIyNTkyODc5NTYyMzQ2MDA1MTAxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | de05f1a4df2cba62e8b909cee8bdb8cb930fe2450c2587fd281ca5c3c0fa52f2 |
| hovercard-subject-tag | issue:257838685 |
| 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/18478/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1399a3542eb9cfedc87baabe8286b463d37b322f4dc9e268f7868330dd0a0bed/microsoft/TypeScript/issues/18478 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1399a3542eb9cfedc87baabe8286b463d37b322f4dc9e268f7868330dd0a0bed/microsoft/TypeScript/issues/18478 |
| og:image:alt | TypeScript Version: Version 2.6.0-dev.20170914 Code function test() { type YesNo = ('No' | 'Yes'); let answer: YesNo = 'No'; // Bug disappears after adding 'as YesNo'. try { answer = 'Yes'; return;... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Zbyl |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width