Title: Flow control resets guarded variables in sub function scope · Issue #8367 · microsoft/TypeScript · GitHub
Open Graph Title: Flow control resets guarded variables in sub function scope · Issue #8367 · microsoft/TypeScript
X Title: Flow control resets guarded variables in sub function scope · Issue #8367 · microsoft/TypeScript
Description: TypeScript Version: nightly (1.9.0-dev.20160429) Code function isFoo(value: any): value is Foo { return value && typeof value.foo === 'function'; } interface Foo { foo(): string; } interface Bar { bar(): string; } function convertBar(inp...
Open Graph Description: TypeScript Version: nightly (1.9.0-dev.20160429) Code function isFoo(value: any): value is Foo { return value && typeof value.foo === 'function'; } interface Foo { foo(): string; } interface Bar { ...
X Description: TypeScript Version: nightly (1.9.0-dev.20160429) Code function isFoo(value: any): value is Foo { return value && typeof value.foo === 'function'; } interface Foo { foo(): string; } ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/8367
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Flow control resets guarded variables in sub function scope","articleBody":"\u003c!--\nThank you for contributing to TypeScript! Please review this checklist\n before submitting your issue.\n[ ] Many common issues and suggestions are addressed in the FAQ\n https://github.com/Microsoft/TypeScript/wiki/FAQ\n[ ] Search for duplicates before logging new issues\n https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue\n[ ] Questions are best asked and answered at Stack Overflow\n http://stackoverflow.com/questions/tagged/typescript\n\nFor bug reports, please include the information below.\n__________________________________________________________ -->\n\n**TypeScript Version:** \n\nnightly (1.9.0-dev.20160429)\n\n**Code**\n\n``` ts\nfunction isFoo(value: any): value is Foo {\n return value && typeof value.foo === 'function';\n}\n\ninterface Foo {\n foo(): string;\n}\n\ninterface Bar {\n bar(): string;\n}\n\nfunction convertBar(input: Foo | Bar): () => string {\n return isFoo(input) ? function () {\n return input.foo(); // \u003c-- Property 'foo' does not exist on type 'Foo | Bar'.\n } : input.bar;\n}\n```\n\n**Expected behavior:**\n\nReceive no errors ([as per 1.8](http://www.typescriptlang.org/play/#src=function%20isFoo%28value%3A%20any%29%3A%20value%20is%20Foo%20%7B%0A%09return%20value%20%26%26%20typeof%20value.foo%20%3D%3D%3D%20'function'%3B%0A%7D%0A%0Ainterface%20Foo%20%7B%0A%09foo%28%29%3A%20string%3B%0A%7D%0A%0Ainterface%20Bar%20%7B%0A%09bar%28%29%3A%20string%3B%0A%7D%0A%0Afunction%20convertBar%28input%3A%20Foo%20%7C%20Bar%29%3A%20%28%29%20%3D%3E%20string%20%7B%0A%09return%20isFoo%28input%29%20%3F%20function%20%28%29%20%7B%0A%09%09return%20input.foo%28%29%3B%0A%09%7D%20%3A%20input.bar%3B%0A%7D%0A))\n\n**Actual behavior:** \n\nReceive the error `Property 'foo' does not exist on type 'Foo | Bar'.`\n","author":{"url":"https://github.com/kitsonk","@type":"Person","name":"kitsonk"},"datePublished":"2016-04-29T06:47:28Z","url":"https://github.com/microsoft/TypeScript/issues/8367"}
| 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:c3fd7ce7-2d76-8e09-79ea-98969ed57075 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B106:14ECB:2D18BC0:395D6FB:6B01B81E |
| html-safe-nonce | ad5865872a8fd1c9f69d47fd592243372de535eae7194e2ba1e45886ae646aab |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTA2OjE0RUNCOjJEMThCQzA6Mzk1RDZGQjo2QjAxQjgxRSIsInZpc2l0b3JfaWQiOiI3MDYyMDMyNDA5NTQxMzI2ODc4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 78d12422dee81a05426166c06bae89f3e254928839cdf6f1ba5b924937d7888e |
| hovercard-subject-tag | issue:151803146 |
| 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/8367/issue_layout |
| twitter:image | https://opengraph.githubassets.com/de9be467828bffd62912fd9929c557ea1c28ee7960df833cb1cf491ce81349c2/microsoft/TypeScript/issues/8367 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/de9be467828bffd62912fd9929c557ea1c28ee7960df833cb1cf491ce81349c2/microsoft/TypeScript/issues/8367 |
| og:image:alt | TypeScript Version: nightly (1.9.0-dev.20160429) Code function isFoo(value: any): value is Foo { return value && typeof value.foo === 'function'; } interface Foo { foo(): string; } interface Bar { ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kitsonk |
| 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