Title: Type guards should be flowed · Issue #10734 · microsoft/TypeScript · GitHub
Open Graph Title: Type guards should be flowed · Issue #10734 · microsoft/TypeScript
X Title: Type guards should be flowed · Issue #10734 · microsoft/TypeScript
Description: type A = number | string function isNumber(_): _ is number { return typeof _ === 'number' } const as: A[] = [1, 2, '3'] // (1) - OK: bs is number[] let bs = as.filter(isNumber) // (2) - Not OK - cs is still A[], but should be number[] le...
Open Graph Description: type A = number | string function isNumber(_): _ is number { return typeof _ === 'number' } const as: A[] = [1, 2, '3'] // (1) - OK: bs is number[] let bs = as.filter(isNumber) // (2) - Not OK - cs...
X Description: type A = number | string function isNumber(_): _ is number { return typeof _ === 'number' } const as: A[] = [1, 2, '3'] // (1) - OK: bs is number[] let bs = as.filter(isNumber) // (...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/10734
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type guards should be flowed","articleBody":"``` ts\ntype A = number | string\nfunction isNumber(_): _ is number { return typeof _ === 'number' }\nconst as: A[] = [1, 2, '3']\n\n// (1) - OK: bs is number[]\nlet bs = as.filter(isNumber)\n\n// (2) - Not OK - cs is still A[], but should be number[]\nlet cs = as.filter(_ => isNumber(_))\n\n// (3) - Not OK - ds is still A[], but should be string[]\nlet ds = as.filter(_ => !isNumber(_))\n```\n\nSimilar issues: https://github.com/Microsoft/TypeScript/issues/7657, https://github.com/Microsoft/TypeScript/issues/5101, https://github.com/Microsoft/TypeScript/issues/5951\n","author":{"url":"https://github.com/bcherny","@type":"Person","name":"bcherny"},"datePublished":"2016-09-06T21:10:10Z","url":"https://github.com/microsoft/TypeScript/issues/10734"}
| 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:c8225639-6dc6-ab2d-4034-351bd99cb141 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A94C:1D8AA1:B6BAAA:F27620:6B00EB47 |
| html-safe-nonce | bf0572068469d9ded17ad5ae4065ee51bdb5f03d5c6ead34e05ce41a5d95ec82 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTRDOjFEOEFBMTpCNkJBQUE6RjI3NjIwOjZCMDBFQjQ3IiwidmlzaXRvcl9pZCI6IjU5Mzg4ODI2MDAzMjMwNTAzMTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fa9cfffbcfdc92d608ad7b3e30d8442141676179a88f9925360ef4fde9b5452b |
| hovercard-subject-tag | issue:175352801 |
| 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/10734/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0356b4965d92153289628c1e4aa75768ee3146cea6868384d906daba1ef5b783/microsoft/TypeScript/issues/10734 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0356b4965d92153289628c1e4aa75768ee3146cea6868384d906daba1ef5b783/microsoft/TypeScript/issues/10734 |
| og:image:alt | type A = number | string function isNumber(_): _ is number { return typeof _ === 'number' } const as: A[] = [1, 2, '3'] // (1) - OK: bs is number[] let bs = as.filter(isNumber) // (2) - Not OK - cs... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bcherny |
| 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