Title: Wrong type narrowing with Boolean(expression) · Issue #37770 · microsoft/TypeScript · GitHub
Open Graph Title: Wrong type narrowing with Boolean(expression) · Issue #37770 · microsoft/TypeScript
X Title: Wrong type narrowing with Boolean(expression) · Issue #37770 · microsoft/TypeScript
Description: TypeScript Version: 3.8.3 Search Terms: Boolean type narrowing Code const x: {test: string} | null | undefined = something() // this works if (!!x) { console.log(x.test) } // this can not work if (Boolean(x)) { console.log(x.test) } Expe...
Open Graph Description: TypeScript Version: 3.8.3 Search Terms: Boolean type narrowing Code const x: {test: string} | null | undefined = something() // this works if (!!x) { console.log(x.test) } // this can not work if (...
X Description: TypeScript Version: 3.8.3 Search Terms: Boolean type narrowing Code const x: {test: string} | null | undefined = something() // this works if (!!x) { console.log(x.test) } // this can not work if (...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/37770
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Wrong type narrowing with Boolean(expression)","articleBody":"**TypeScript Version:** 3.8.3\r\n\r\n**Search Terms:** Boolean type narrowing\r\n\r\n**Code**\r\n\r\n```ts\r\n const x: {test: string} | null | undefined = something()\r\n\r\n // this works\r\n if (!!x) {\r\n console.log(x.test)\r\n }\r\n\r\n // this can not work\r\n if (Boolean(x)) {\r\n console.log(x.test)\r\n }\r\n```\r\n\r\n**Expected behavior:**\r\nExpression inside the second if statement should work.\r\n\r\n\r\n**Actual behavior:**\r\nThe second if statement gives the following error:\r\n```\r\nTS2533: Object is possibly 'null' or 'undefined'.\r\n```\r\n\r\n**Related Issues:** None\r\n","author":{"url":"https://github.com/Felix-Indoing","@type":"Person","name":"Felix-Indoing"},"datePublished":"2020-04-03T13:16:23Z","url":"https://github.com/microsoft/TypeScript/issues/37770"}
| 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:8f18d011-72b8-5584-a6a0-a73cc32b6aef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84AA:B53AF:9E363C:D45294:6B00EA97 |
| html-safe-nonce | 3df33a5dd94c8cd1e03aec619f5f071ec2f3683c2a7f3a9ede81c7b3a0feb242 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEFBOkI1M0FGOjlFMzYzQzpENDUyOTQ6NkIwMEVBOTciLCJ2aXNpdG9yX2lkIjoiNDY2MTQ0NjYwMDc4MDk5OTMxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 874500e460f00ba1f17491e7026680d9651182b7bbf493d66f00f8a4e8e4e057 |
| hovercard-subject-tag | issue:593374946 |
| 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/37770/issue_layout |
| twitter:image | https://opengraph.githubassets.com/31f4b98d9e500dbc1975191e94609c75dcfb4b34e16657cc6424d9697114ec94/microsoft/TypeScript/issues/37770 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/31f4b98d9e500dbc1975191e94609c75dcfb4b34e16657cc6424d9697114ec94/microsoft/TypeScript/issues/37770 |
| og:image:alt | TypeScript Version: 3.8.3 Search Terms: Boolean type narrowing Code const x: {test: string} | null | undefined = something() // this works if (!!x) { console.log(x.test) } // this can not work if (... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Felix-Indoing |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width