Title: Type narrowing bug in empty interfaces · Issue #18196 · microsoft/TypeScript · GitHub
Open Graph Title: Type narrowing bug in empty interfaces · Issue #18196 · microsoft/TypeScript
X Title: Type narrowing bug in empty interfaces · Issue #18196 · microsoft/TypeScript
Description: Reproduction (turn on strictNullChecks to see the red line) let x: {} = ""; if (!x) { // x is `never` O_O }
Open Graph Description: Reproduction (turn on strictNullChecks to see the red line) let x: {} = ""; if (!x) { // x is `never` O_O }
X Description: Reproduction (turn on strictNullChecks to see the red line) let x: {} = ""; if (!x) { // x is `never` O_O }
Opengraph URL: https://github.com/microsoft/TypeScript/issues/18196
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type narrowing bug in empty interfaces","articleBody":"[Reproduction](https://www.typescriptlang.org/play/#src=type%20Opaque%20%3D%20%7B%7D%20%7C%20null%20%7C%20undefined%20%7C%20void%3B%0D%0A%0D%0Afunction%20foo(value%3A%20Opaque)%3A%20void%20%7B%0D%0A%20%20if%20(value%20%7C%7C%20value%20%3D%3D%3D%200)%20%7B%0D%0A%20%20%20%20%2F%2F%20...%0D%0A%20%20%7D%20else%20%7B%0D%0A%20%20%20%20%2F%2F%20...%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0A%2F%2F%20You%20can%20see%20what%20is%20causing%20this%20bug%20here%3A%0D%0A%0D%0Ainterface%20Anything%20%7B%20%7D%0D%0A%0D%0Afunction%20bar(value%3A%20Anything)%20%7B%0D%0A%20%20if%20(value%20%7C%7C%20%2F*%20hover%20here%20-%3E%20*%2F%20value%20%2F*%20%3C-%20value%20is%20%22never%22%20*%2F%20%3D%3D%3D%200)%20%7B%20%0D%0A%0D%0A%20%20%7D%0D%0A%7D%0D%0A) (turn on `strictNullChecks` to see the red line)\r\n\r\n```ts\r\nlet x: {} = \"\";\r\n\r\nif (!x) {\r\n // x is `never` O_O\r\n}\r\n```","author":{"url":"https://github.com/chancancode","@type":"Person","name":"chancancode"},"datePublished":"2017-09-01T00:58:00Z","url":"https://github.com/microsoft/TypeScript/issues/18196"}
| 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:aff89817-45ee-39bc-b045-5fd3b1fc2d6d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 92D8:181E33:1A00D9:23A2F9:6B04B432 |
| html-safe-nonce | 64051bb01c159c67e6b80fcce42256ee3adb23a5e654cd9d12f4465d4d0571dd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MkQ4OjE4MUUzMzoxQTAwRDk6MjNBMkY5OjZCMDRCNDMyIiwidmlzaXRvcl9pZCI6Ijg0OTA4MTc1MDc0OTY4NjY4NjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0f84627c0e70a114e8b18fb38b90a9f689a5f89523a5f6ee59a98e55c3dfedf8 |
| hovercard-subject-tag | issue:254508233 |
| 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/18196/issue_layout |
| twitter:image | https://opengraph.githubassets.com/64d2ff2e71cc449289c0c855e89d7fdfccc71d07dc711d4a7f9b1d256dd9d9f1/microsoft/TypeScript/issues/18196 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/64d2ff2e71cc449289c0c855e89d7fdfccc71d07dc711d4a7f9b1d256dd9d9f1/microsoft/TypeScript/issues/18196 |
| og:image:alt | Reproduction (turn on strictNullChecks to see the red line) let x: {} = ""; if (!x) { // x is `never` O_O } |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chancancode |
| 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