Title: strictNullChecks thinks a value may be null if null is assigned to it in its non-null branch · Issue #7630 · microsoft/TypeScript · GitHub
Open Graph Title: strictNullChecks thinks a value may be null if null is assigned to it in its non-null branch · Issue #7630 · microsoft/TypeScript
X Title: strictNullChecks thinks a value may be null if null is assigned to it in its non-null branch · Issue #7630 · microsoft/TypeScript
Description: TypeScript Version: 3853bb8 (master after merging #7140 ) Code class Prop { value: any; } var x: Prop | null = null; if (x === null) { ; } else if (x.value === null) { // Line 9 x = null; } tsc -t es5 --strictNullChecks ./foo.ts Expected...
Open Graph Description: TypeScript Version: 3853bb8 (master after merging #7140 ) Code class Prop { value: any; } var x: Prop | null = null; if (x === null) { ; } else if (x.value === null) { // Line 9 x = null; } tsc -t ...
X Description: TypeScript Version: 3853bb8 (master after merging #7140 ) Code class Prop { value: any; } var x: Prop | null = null; if (x === null) { ; } else if (x.value === null) { // Line 9 x = null; } tsc -t ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/7630
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"strictNullChecks thinks a value may be null if null is assigned to it in its non-null branch","articleBody":"**TypeScript Version:** \n\nhttps://github.com/Microsoft/TypeScript/commit/3853bb86d0f26e150666ab736092824eb781babc (master after merging #7140 )\n\n**Code**\n\n``` ts\nclass Prop {\n value: any;\n}\n\nvar x: Prop | null = null;\nif (x === null) {\n ;\n}\nelse if (x.value === null) { // Line 9\n x = null;\n}\n```\n\n`tsc -t es5 --strictNullChecks ./foo.ts`\n\n**Expected behavior:**\n\nCompiles.\n\n**Actual behavior:** \n\n`foo.ts(9,10): error TS2531: Object is possibly 'null' or 'undefined'.`\n\n---\n\nIf the `x = null;` assignment (line 10) is removed, it does compile, and `x` is correctly inferred to be non-null in the condition and body of the else-if block. But this assignment should not have any effect on the nullability of x in the else-if condition.\n","author":{"url":"https://github.com/Arnavion","@type":"Person","name":"Arnavion"},"datePublished":"2016-03-22T08:10:28Z","url":"https://github.com/microsoft/TypeScript/issues/7630"}
| 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:c998b31d-373d-9f24-4827-1f69d7d7abf4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E13C:1637A3:4FCA53:6B58E8:6AFBF044 |
| html-safe-nonce | b092272517504c59fa19484eaf4cf8839e59c156b8d7cf4dcd3db230540d4400 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTNDOjE2MzdBMzo0RkNBNTM6NkI1OEU4OjZBRkJGMDQ0IiwidmlzaXRvcl9pZCI6IjUzMTk0MjQyMTY0Mjg2Njc1NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3dabaecc5c1d1121875c2449121509d8c2f604724c3566fe370f2dc5413de109 |
| hovercard-subject-tag | issue:142577296 |
| 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/7630/issue_layout |
| twitter:image | https://opengraph.githubassets.com/12aa658bbb1fd4b3dfc3023976dd1cb1bef654e4af8b1f56132922579878d728/microsoft/TypeScript/issues/7630 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/12aa658bbb1fd4b3dfc3023976dd1cb1bef654e4af8b1f56132922579878d728/microsoft/TypeScript/issues/7630 |
| og:image:alt | TypeScript Version: 3853bb8 (master after merging #7140 ) Code class Prop { value: any; } var x: Prop | null = null; if (x === null) { ; } else if (x.value === null) { // Line 9 x = null; } tsc -t ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Arnavion |
| hostname | github.com |
| expected-hostname | github.com |
| None | fa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f |
| 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 | b3b5633a74535d9c23385512d534c66c8fde1907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width