Title: undefined is narrowed away incorrectly · Issue #60106 · microsoft/TypeScript · GitHub
Open Graph Title: undefined is narrowed away incorrectly · Issue #60106 · microsoft/TypeScript
X Title: undefined is narrowed away incorrectly · Issue #60106 · microsoft/TypeScript
Description: 🔎 Search Terms narrowing undefined, incorrect type narrowing, incorrect if statement narrowing 🕗 Version & Regression Information This changed between versions 5.2 and 5.3 ⏯ Playground Link https://www.typescriptlang.org/play/?#code/CYUw...
Open Graph Description: 🔎 Search Terms narrowing undefined, incorrect type narrowing, incorrect if statement narrowing 🕗 Version & Regression Information This changed between versions 5.2 and 5.3 ⏯ Playground Link https:/...
X Description: 🔎 Search Terms narrowing undefined, incorrect type narrowing, incorrect if statement narrowing 🕗 Version & Regression Information This changed between versions 5.2 and 5.3 ⏯ Playground Link htt...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/60106
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"undefined is narrowed away incorrectly","articleBody":"### 🔎 Search Terms\r\n\r\nnarrowing undefined, incorrect type narrowing, incorrect if statement narrowing\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This changed between versions 5.2 and 5.3\r\n\r\n### ⏯ Playground Link\r\n\r\nhttps://www.typescriptlang.org/play/?#code/CYUwxgNghgTiAEkoGdnwILwN4CgCQAksugBQCUAXPAC4AWAlmoxgNw4C+OOoSciA9gDtk1eAAco1aiBiCqmAD7wAroNAAzeoJDA261WGr0h8KGLEQAngAVJ02eWz566+CQlSZggPwA6IqRk8AC8ofDqUBDIIEG4eHge9oJs8QD0qfAAet74eHDUyrIpnAl2XinpWTnsQA\r\n\r\n### 💻 Code\r\n\r\n```ts\r\ndeclare class A {\r\n\tIsA(): this is A;\r\n}\r\n\r\ndeclare const pattern: A | undefined;\r\nfunction applyPattern() {\r\n\tif (pattern?.IsA() === false) {\r\n\t\tpattern;\r\n\t\t// ^?\r\n\t\treturn;\r\n\t}\r\n\tpattern;\r\n\t// ^?\r\n}\r\n```\r\n\r\n\r\n### 🙁 Actual behavior\r\n\r\n`pattern` is narrowed down to `A`, removing the undefined\r\n\r\n### 🙂 Expected behavior\r\n\r\n`pattern` should only be narrowed to `A | undefined`\r\n\r\n### Additional information about the issue\r\n\r\n_No response_","author":{"url":"https://github.com/TrippTrapp84","@type":"Person","name":"TrippTrapp84"},"datePublished":"2024-09-30T15:20:49Z","url":"https://github.com/microsoft/TypeScript/issues/60106"}
| 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:c65c824a-ee06-e0af-d45c-f33da791a95e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC20:27D3AD:21930BC:2A91198:6B0173DE |
| html-safe-nonce | b0437be99d89d9c79b030574eee97dc3b51e5bd23b4acf9b64a08b1521631409 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzIwOjI3RDNBRDoyMTkzMEJDOjJBOTExOTg6NkIwMTczREUiLCJ2aXNpdG9yX2lkIjoiNTE2NTA1NzgwNTczMTg1MzI3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5434bd227a9d56ffe187344e40ecbd0aa1c2d084ebb31c5156ea265318306b9e |
| hovercard-subject-tag | issue:2556992186 |
| 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/60106/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1f874bd84447e733dcdb1ecba5d9bd99871e26d970e03e6ee63ae31c7c045495/microsoft/TypeScript/issues/60106 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1f874bd84447e733dcdb1ecba5d9bd99871e26d970e03e6ee63ae31c7c045495/microsoft/TypeScript/issues/60106 |
| og:image:alt | 🔎 Search Terms narrowing undefined, incorrect type narrowing, incorrect if statement narrowing 🕗 Version & Regression Information This changed between versions 5.2 and 5.3 ⏯ Playground Link https:/... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | TrippTrapp84 |
| 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