Title: .every() .find() .filter() methods fail with "This expression is not callable." error on union of array types · Issue #44373 · microsoft/TypeScript · GitHub
Open Graph Title: .every() .find() .filter() methods fail with "This expression is not callable." error on union of array types · Issue #44373 · microsoft/TypeScript
X Title: .every() .find() .filter() methods fail with "This expression is not callable." error on union of array types · Issue #44373 · microsoft/TypeScript
Description: Bug Report 🔎 Search Terms This expression is not callable none of those signatures are compatible with each other 🕗 Version & Regression Information This is the behavior in every version I tried, and I reviewed the FAQ for entries about ...
Open Graph Description: Bug Report 🔎 Search Terms This expression is not callable none of those signatures are compatible with each other 🕗 Version & Regression Information This is the behavior in every version I tried, a...
X Description: Bug Report 🔎 Search Terms This expression is not callable none of those signatures are compatible with each other 🕗 Version & Regression Information This is the behavior in every version I trie...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/44373
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":".every() .find() .filter() methods fail with \"This expression is not callable.\" error on union of array types","articleBody":"# Bug Report\r\n\r\n\u003c!--\r\n Please fill in each section completely. Thank you!\r\n-->\r\n\r\n### 🔎 Search Terms\r\n\r\n- This expression is not callable\r\n- none of those signatures are compatible with each other\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This is the behavior in every version I tried, and I reviewed the FAQ for entries about union types. I also reviewed previous related issues.\r\n\r\n### ⏯ Playground Link\r\n\r\n- .every() [does not work](https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgGLAF4eQbwLABQyxywAJgFzIgCuAtgEbQDchJyMmGVAzmFKADmrAgF9ChUJFiIUAIRpZcbEuSq1GLFcQaLuyPgJDDC4goQAUAbQC6yODzRdbyAD7IFWWwEoAdBAA3aABPC2BIOmQAXgA+Ugjfcm9mZCA)\r\n- .filter() [does not work](https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgGLAF4eQbwLABQyxywAJgFzIgCuAtgEbQDchJyMmGVAzmFKADmrAgF9ChUJFiIUAIRpZcbEuSq1GLFcQaLuyPgJDDC4goQAUAbQC6yODzRdbyAD7IFWWwEoAdJwAbaQtgSDpkAF4APlIw33JvZmQgA)\r\n- .find() [does not work](https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgGLAF4eQbwLABQyxywAJgFzIgCuAtgEbQDchJyMmGVAzmFKADmrAgF9ChUJFiIUAIRpZcbEuSq1GLFcQaLuyPgJDDC4goQAUAbQC6yODzRdbyAD7IFWWwEoAdJxAyC2BIOmQAXgA+UlDfcm9mZCA)\r\n- .reduce() also doesn't work, but there is already an [issue](https://github.com/microsoft/TypeScript/issues/44063) for that one. (Perhaps we should merge it into this?)\r\n\r\n### 💻 Code\r\n\r\n\u003c!-- Please post the relevant code sample here as well-->\r\n```ts\r\ninterface Fizz {\r\n id: number;\r\n fizz: string;\r\n}\r\n\r\ninterface Buzz {\r\n id: number;\r\n buzz: string;\r\n}\r\n\r\n([] as Fizz[] | Buzz[]).filter(item => item.id \u003c 5); \r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nCompilation fails with the following error:\r\n```\r\nThis expression is not callable.\r\n Each member of the union type '{ \u003cS extends Fizz>(predicate: (value: Fizz, index: number, array: Fizz[]) => value is S, thisArg?: any): S[]; (predicate: (value: Fizz, index: number, array: Fizz[]) => unknown, thisArg?: any): Fizz[]; } | { ...; }' has signatures, but none of those signatures are compatible with each other.\r\n```\r\n\r\n### 🙂 Expected behavior\r\n\r\nCompilation succeeds, as it does for [map and several other array functions](https://github.com/microsoft/TypeScript/issues/36390#issuecomment-852533093).\r\n\r\n### 🔖 Useful links\r\n- [Original issue](https://github.com/microsoft/TypeScript/issues/36390)\r\n- [PR that closed original issue](https://github.com/microsoft/TypeScript/pull/31023)","author":{"url":"https://github.com/ialexryan","@type":"Person","name":"ialexryan"},"datePublished":"2021-06-01T22:41:54Z","url":"https://github.com/microsoft/TypeScript/issues/44373"}
| 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:ffe4aa8d-a561-4e93-fba4-353872b2543d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C482:269AD9:7D4166:A9AD96:6B00DF5F |
| html-safe-nonce | 36d3151602da15ab7f6bc1c9d31f7997329da98e2d5b8266f782952b68dada8a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDgyOjI2OUFEOTo3RDQxNjY6QTlBRDk2OjZCMDBERjVGIiwidmlzaXRvcl9pZCI6IjE5NzIzNjMxNTcyMzQwNDg4NjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fd97c2ca2c3f37a7c9f7622171a1099e2729a3520fb96ac175f61ff30857c908 |
| hovercard-subject-tag | issue:908784746 |
| 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/44373/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2937c8c0ebed06ef2f312ea8a8bbf03619226a64a94cfb742efa36540342b094/microsoft/TypeScript/issues/44373 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2937c8c0ebed06ef2f312ea8a8bbf03619226a64a94cfb742efa36540342b094/microsoft/TypeScript/issues/44373 |
| og:image:alt | Bug Report 🔎 Search Terms This expression is not callable none of those signatures are compatible with each other 🕗 Version & Regression Information This is the behavior in every version I tried, a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ialexryan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width