Title: Strict null checks and flow control of returned functions · Issue #9263 · microsoft/TypeScript · GitHub
Open Graph Title: Strict null checks and flow control of returned functions · Issue #9263 · microsoft/TypeScript
X Title: Strict null checks and flow control of returned functions · Issue #9263 · microsoft/TypeScript
Description: TypeScript Version: Version 1.9.0-dev.20160619-1.0 Code function doThing (x?: { prop: boolean }) { if (x == null) { return function () { throw new TypeError('Not correctly set up') } } return function () { return x.prop } } { "compilerOp...
Open Graph Description: TypeScript Version: Version 1.9.0-dev.20160619-1.0 Code function doThing (x?: { prop: boolean }) { if (x == null) { return function () { throw new TypeError('Not correctly set up') } } return funct...
X Description: TypeScript Version: Version 1.9.0-dev.20160619-1.0 Code function doThing (x?: { prop: boolean }) { if (x == null) { return function () { throw new TypeError('Not correctly set up') } } retu...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/9263
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Strict null checks and flow control of returned functions","articleBody":"**TypeScript Version:** \n\nVersion 1.9.0-dev.20160619-1.0\n\n**Code**\n\n``` ts\nfunction doThing (x?: { prop: boolean }) {\n if (x == null) {\n return function () {\n throw new TypeError('Not correctly set up')\n }\n }\n\n return function () {\n return x.prop\n }\n}\n```\n\n``` json\n{\n \"compilerOptions\": {\n \"strictNullChecks\": true\n }\n}\n```\n\n**Expected behavior:** Successful compilation.\n\n**Actual behavior:** \n\n```\nindex.ts(9,12): error TS2532: Object is possibly 'undefined'.\n```\n\nI honestly wasn't sure what this exact feature would be called to find a duplicate, and I know I've logged a similar issues issues in the past. Let me know if a duplicate does exist. In any case, I would expect flow control to have understood the undefined case was already handled. I suppose this could be related to the fact the arguments are mutable? Is it possible to use flow control analysis to understand nothing re-assigns the value (in fact, nothing else even executes) after that return?\n","author":{"url":"https://github.com/blakeembrey","@type":"Person","name":"blakeembrey"},"datePublished":"2016-06-20T04:58:23Z","url":"https://github.com/microsoft/TypeScript/issues/9263"}
| 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:ea1a952d-5349-c858-5cad-82255719a546 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9E82:1CEA6F:C52BAF:1060008:6B00F39C |
| html-safe-nonce | c1225dfdce1d91a1b011417bff51eb9157d3fe96fc71bff18281fda6902fa2a0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RTgyOjFDRUE2RjpDNTJCQUY6MTA2MDAwODo2QjAwRjM5QyIsInZpc2l0b3JfaWQiOiIzMTg3MzE3OTk5Nzc4NDYwNTcyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f5c63881c130b31f083d0a33368133b612f733c6fe4b4b775f7a6091e107e26c |
| hovercard-subject-tag | issue:161117039 |
| 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/9263/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bbb2940122e4a22691decf010a08608f83bbe2cc42235a39737b6207d8b6a08b/microsoft/TypeScript/issues/9263 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bbb2940122e4a22691decf010a08608f83bbe2cc42235a39737b6207d8b6a08b/microsoft/TypeScript/issues/9263 |
| og:image:alt | TypeScript Version: Version 1.9.0-dev.20160619-1.0 Code function doThing (x?: { prop: boolean }) { if (x == null) { return function () { throw new TypeError('Not correctly set up') } } return funct... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | blakeembrey |
| 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