Title: Void type narrowing stops working in callbacks · Issue #8541 · microsoft/TypeScript · GitHub
Open Graph Title: Void type narrowing stops working in callbacks · Issue #8541 · microsoft/TypeScript
X Title: Void type narrowing stops working in callbacks · Issue #8541 · microsoft/TypeScript
Description: Seems like this would have been reported, but I had trouble finding a duplicate issue. Feel free to close if one does exist. TypeScript Version: nightly (1.9.0-dev.20160217) Code let foo: string | void let cbr: (cb: (err: Error) => any) ...
Open Graph Description: Seems like this would have been reported, but I had trouble finding a duplicate issue. Feel free to close if one does exist. TypeScript Version: nightly (1.9.0-dev.20160217) Code let foo: string | ...
X Description: Seems like this would have been reported, but I had trouble finding a duplicate issue. Feel free to close if one does exist. TypeScript Version: nightly (1.9.0-dev.20160217) Code let foo: string | ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/8541
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Void type narrowing stops working in callbacks","articleBody":"Seems like this would have been reported, but I had trouble finding a duplicate issue. Feel free to close if one does exist.\n\n**TypeScript Version:** \n\nnightly (1.9.0-dev.20160217)\n\n**Code**\n\n``` ts\nlet foo: string | void\nlet cbr: (cb: (err: Error) => any) => any\n\nif (foo) {\n cbr(function () {\n foo.substr(0, 10)\n })\n}\n```\n\n**Expected behavior:** No error\n\n**Actual behavior:**\n\n```\nindex.ts(6,9): error TS2339: Property 'substr' does not exist on type 'string | void'.\n```\n\nEdit: Only visible on nightly - notice that in nightly `foo.substr` within the `if (foo)` is valid, but not within the callback function which is also inside `if (foo)`.\n","author":{"url":"https://github.com/blakeembrey","@type":"Person","name":"blakeembrey"},"datePublished":"2016-05-10T06:28:13Z","url":"https://github.com/microsoft/TypeScript/issues/8541"}
| 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:83f0b5d0-4977-d6ed-5e41-15b3d0ec75ea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA1A:14EB6E:98C676:C8B745:6B01B4B8 |
| html-safe-nonce | 160d43271926ea6fc4638d596166b3dc969f0cde1e004c215725c978273355ef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTFBOjE0RUI2RTo5OEM2NzY6QzhCNzQ1OjZCMDFCNEI4IiwidmlzaXRvcl9pZCI6IjY3NjMzNTY5NjkyNzg0ODU2ODgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7f7c5fbc3fd4b917a4bc3c5e436deac8fa7c40bb55049aa2841d01914979c990 |
| hovercard-subject-tag | issue:153932627 |
| 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/8541/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c2c14dc63a649c860be267c133eea6bae23fa18df424d2e7fa36cd73df4b3506/microsoft/TypeScript/issues/8541 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c2c14dc63a649c860be267c133eea6bae23fa18df424d2e7fa36cd73df4b3506/microsoft/TypeScript/issues/8541 |
| og:image:alt | Seems like this would have been reported, but I had trouble finding a duplicate issue. Feel free to close if one does exist. TypeScript Version: nightly (1.9.0-dev.20160217) Code let foo: string | ... |
| 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 | 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