Title: Infer Type Guard Return Values · Issue #5101 · microsoft/TypeScript · GitHub
Open Graph Title: Infer Type Guard Return Values · Issue #5101 · microsoft/TypeScript
X Title: Infer Type Guard Return Values · Issue #5101 · microsoft/TypeScript
Description: If a function returns a type guard, either the result of an instanceofor the return value of another type guard function, it could be inferred as being a type guard itself. However, it is simply inferred as a boolean. This change would a...
Open Graph Description: If a function returns a type guard, either the result of an instanceofor the return value of another type guard function, it could be inferred as being a type guard itself. However, it is simply in...
X Description: If a function returns a type guard, either the result of an instanceofor the return value of another type guard function, it could be inferred as being a type guard itself. However, it is simply in...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/5101
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Infer Type Guard Return Values","articleBody":"If a function returns a type guard, either the result of an `instanceof`or the return value of another type guard function, it could be inferred as being a type guard itself. However, it is simply inferred as a `boolean`.\n\nThis change would allow the following code to work: \n\n``` typescript\n// The interface below should probably be merged into lib.d.ts and friends.\ninterface Array\u003cT> {\n filter\u003cO extends T>(callbackfn: (value: T, index: number, array: T[]) => value is O, thisArg?: any): O[];\n}\n\ndeclare class Foo { bar: number }\n\ndeclare var blah: Object[];\n\nblah.filter(object => object instanceof Foo)[0].bar // Property bar does not exist on type object\n```\n","author":{"url":"https://github.com/Gaelan","@type":"Person","name":"Gaelan"},"datePublished":"2015-10-04T04:23:53Z","url":"https://github.com/microsoft/TypeScript/issues/5101"}
| 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:71816d89-c420-dcb0-258a-f985a3ea9f2a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D138:34DB8F:CBE4BF:1112E1C:6B0101AF |
| html-safe-nonce | 675b0dca1769b31f1b61b4bdddd5c8de3891997df436e4477c385edd217acc14 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTM4OjM0REI4RjpDQkU0QkY6MTExMkUxQzo2QjAxMDFBRiIsInZpc2l0b3JfaWQiOiI2NTU0Nzc3MDY5ODQ1ODc2OTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6847dd1b8a0040c61a7f2c2df8a9ffb521f634ce70f5311f91647a1d87044655 |
| hovercard-subject-tag | issue:109662484 |
| 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/5101/issue_layout |
| twitter:image | https://opengraph.githubassets.com/da6cc9aec93dfdf173f777f9b38ab188e864f83c2bea6ba8e8bbbd95a5b102d1/microsoft/TypeScript/issues/5101 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/da6cc9aec93dfdf173f777f9b38ab188e864f83c2bea6ba8e8bbbd95a5b102d1/microsoft/TypeScript/issues/5101 |
| og:image:alt | If a function returns a type guard, either the result of an instanceofor the return value of another type guard function, it could be inferred as being a type guard itself. However, it is simply in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Gaelan |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width