Title: Add BooleanConstructor as an overload to .filter to allow for easy type predicate filtering · Issue #50387 · microsoft/TypeScript · GitHub
Open Graph Title: Add BooleanConstructor as an overload to .filter to allow for easy type predicate filtering · Issue #50387 · microsoft/TypeScript
X Title: Add BooleanConstructor as an overload to .filter to allow for easy type predicate filtering · Issue #50387 · microsoft/TypeScript
Description: lib Update Request Configuration Check My compilation target is ES2015 and my lib is the default. Missing / Incorrect Definition I would love to add an overload to Array.filter which takes in a common use case of passing a Boolean direct...
Open Graph Description: lib Update Request Configuration Check My compilation target is ES2015 and my lib is the default. Missing / Incorrect Definition I would love to add an overload to Array.filter which takes in a com...
X Description: lib Update Request Configuration Check My compilation target is ES2015 and my lib is the default. Missing / Incorrect Definition I would love to add an overload to Array.filter which takes in a com...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/50387
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add BooleanConstructor as an overload to .filter to allow for easy type predicate filtering","articleBody":"# lib Update Request\r\n\r\n## Configuration Check\r\n\r\nMy compilation *target* is `ES2015` and my *lib* is `the default`.\r\n\r\n## Missing / Incorrect Definition\r\n\r\nI would love to add an overload to Array.filter which takes in a common use case of passing a `Boolean` directly to `.filter`. This would offer a simple, intuitive workaround for a common pain point with `.filter`.\r\n\r\nThis could be achieved via an overload adding `BooleanConstructor`, and a type predicate.\r\n\r\nhttps://www.typescriptlang.org/play?#code/PTAEHUEsBcAtTgU1AewG6IE4BsUEMATAWACgBjFAOwGdpQ9NNQBeUAbQCIBGDgGlACulAogBmkSogIBdANykQoJaAB6AflKkJ0LKLxlkAQUZ4AngB4AKgD5QAb1JLx2HZgAUAB0xTIZPDoAuUAAhFBRsRDxKAGEqWkwBMmgUTABKIIA5KgAxPGxqCxs2OVIAX00SaFMPZCzKXPzC21ZLUEQADx1halAABlAAH1AAcmHB0EoBbGxxoRFxSQJQNQnEDCYgy3kSUgoaOmdXKWMmVgZMADpDrDdQ8MjKVO3FZXUgA\r\n\r\n## Sample Code\r\n\r\n```ts\r\nconst arr = ['1', undefined];\r\n\r\nconst filteredArr = arr.filter(Boolean);\r\n```\r\n\r\n`filteredArr` should be `string[]`, not `(string | undefined)[]`.","author":{"url":"https://github.com/mattpocock","@type":"Person","name":"mattpocock"},"datePublished":"2022-08-21T07:43:56Z","url":"https://github.com/microsoft/TypeScript/issues/50387"}
| 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:009e9812-ad14-5bd5-67c2-457134502402 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD3A:27D3AD:753EAD:96A849:6B00E3FE |
| html-safe-nonce | 263a4d54c62bb685664e217cc6c33f33958a9dac38db08fdfd02b23c4e05b2e4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDNBOjI3RDNBRDo3NTNFQUQ6OTZBODQ5OjZCMDBFM0ZFIiwidmlzaXRvcl9pZCI6IjEwMjMzODYyODA1OTcxODU1MzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 445d03c7816d2456359ebd327fb4168a5acfaa9ab2ded647bea4e0a929401c3b |
| hovercard-subject-tag | issue:1345413331 |
| 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/50387/issue_layout |
| twitter:image | https://opengraph.githubassets.com/638575817cc9180fa9093fd36fa4d06af8159dcf664dc46af35e5b611d866574/microsoft/TypeScript/issues/50387 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/638575817cc9180fa9093fd36fa4d06af8159dcf664dc46af35e5b611d866574/microsoft/TypeScript/issues/50387 |
| og:image:alt | lib Update Request Configuration Check My compilation target is ES2015 and my lib is the default. Missing / Incorrect Definition I would love to add an overload to Array.filter which takes in a com... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mattpocock |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| 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 | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width