Title: Adding an overload to .filter breaks specific inference with nested functions · Issue #56013 · microsoft/TypeScript · GitHub
Open Graph Title: Adding an overload to .filter breaks specific inference with nested functions · Issue #56013 · microsoft/TypeScript
X Title: Adding an overload to .filter breaks specific inference with nested functions · Issue #56013 · microsoft/TypeScript
Description: 🔎 Search Terms "filter inference overload", "filter boolean" 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about inferred types ⏯ Playground Link https://tsplay.dev/w...
Open Graph Description: 🔎 Search Terms "filter inference overload", "filter boolean" 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about inferred type...
X Description: 🔎 Search Terms "filter inference overload", "filter boolean" 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for ent...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/56013
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Adding an overload to .filter breaks specific inference with nested functions","articleBody":"### 🔎 Search Terms\n\n\"filter inference overload\", \"filter boolean\"\n\n### 🕗 Version & Regression Information\n\n- This is the behavior in every version I tried, and I reviewed the FAQ for entries about inferred types \r\n\n\n### ⏯ Playground Link\n\nhttps://tsplay.dev/wQbrvN\n\n### 💻 Code\n\n```ts\r\ntype NonFalsy\u003cT> = T extends false | 0 | \"\" | null | undefined | 0n\r\n ? never\r\n : T;\r\n\r\n// Comment this out\r\ninterface Array\u003cT> { filter(predicate: BooleanConstructor, thisArg?: any): NonFalsy\u003cT>[]; }\r\n\r\nconst id = \u003cT,>() => (t: T) => !!t;\r\n\r\n['foo', 'bar'].filter(id())\r\n// ^?\r\n```\r\n\n\n### 🙁 Actual behavior\n\nNested function inference works (type parameter is `string`) without the additional overload, and fails (type parameter is `unknown`) with the overload (even though the added overload isn't the one in use).\n\n### 🙂 Expected behavior\n\nNested function inference should work regardless of whether an overload is added to .filter or not.\n\n### Additional information about the issue\n\nAdding the overload is described in https://github.com/microsoft/TypeScript/issues/50387 and made popular by `ts-reset`. \r\nIt's possible the overload *order* may matter in this instance, but difficult to test when the main overloads are coming from lib definitions.","author":{"url":"https://github.com/EskiMojo14","@type":"Person","name":"EskiMojo14"},"datePublished":"2023-10-06T19:37:59Z","url":"https://github.com/microsoft/TypeScript/issues/56013"}
| 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:b6964a08-1c51-84a3-f791-e0d94551d673 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CEA6:3897F3:A7F424:DA83F8:6B00E79F |
| html-safe-nonce | 1a82b285b6170f3704d5ed169bbcc3657496ddd427286da818f0e5ff494a9b7f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRUE2OjM4OTdGMzpBN0Y0MjQ6REE4M0Y4OjZCMDBFNzlGIiwidmlzaXRvcl9pZCI6IjE0NzM0MjU0MTc4NjcxNTk0NTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f8cf0382fa4cbed8f4f4efc01c433361fde354e6f826d4886a78d7b66ee570cc |
| hovercard-subject-tag | issue:1930837956 |
| 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/56013/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d221a89f552e41e0c7bf5d5d6ede0d0e9bf7392d2fcd099149ef8fc79c86691/microsoft/TypeScript/issues/56013 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d221a89f552e41e0c7bf5d5d6ede0d0e9bf7392d2fcd099149ef8fc79c86691/microsoft/TypeScript/issues/56013 |
| og:image:alt | 🔎 Search Terms "filter inference overload", "filter boolean" 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about inferred type... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | EskiMojo14 |
| 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