Title: Cannot use "map" on a type of Array
Open Graph Title: Cannot use "map" on a type of Array
X Title: Cannot use "map" on a type of Array
Description: 🐞 bug report Affected Package The issue is caused by package @angular/core. Is this a regression? No. Description I have a function that I wish to work with both QueryList and Array. Both types have the map method, but their types are no...
Open Graph Description: 🐞 bug report Affected Package The issue is caused by package @angular/core. Is this a regression? No. Description I have a function that I wish to work with both QueryList and Array. Both types hav...
X Description: 🐞 bug report Affected Package The issue is caused by package @angular/core. Is this a regression? No. Description I have a function that I wish to work with both QueryList and Array. Both types hav...
Opengraph URL: https://github.com/angular/angular/issues/39602
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot use \"map\" on a type of Array\u003cT> | QueryList\u003cT> because of signature mismatches","articleBody":"# 🐞 bug report\r\n\r\n### Affected Package\r\n\u003c!-- Can you pin-point one or more @angular/* packages as the source of the bug? -->\r\n\u003c!-- ✍️edit: --> \r\nThe issue is caused by package `@angular/core`.\r\n\r\n\r\n### Is this a regression?\r\n\r\n\u003c!-- Did this behavior use to work in the previous version? -->\r\n\u003c!-- ✍️--> No.\r\n\r\n\r\n### Description\r\n\r\n\u003c!-- ✍️--> \r\nI have a function that I wish to work with both `QueryList` and `Array`. Both types have the `map` method, but their types are not inter-compatible:\r\n\r\n```text\r\nError:(7, 12) TS2349: This expression is not callable.\r\n Each member of the union type '(\u003cU>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[]) | (\u003cU>(fn: (item: any, index: number, array: any[]) => U) => U[])' has signatures, but none of those signatures are compatible with each other.\r\n```\r\n\r\n\r\n## 🔬 Minimal Reproduction\r\n\u003c!--\r\nPlease create and share minimal reproduction of the issue starting with this template: https://stackblitz.com/fork/angular-ivy\r\n-->\r\n\u003c!-- ✍️--> Trivial to try out and quickly reproduce in any project you have open by writing this:\r\n\r\n```ts\r\nimport { QueryList } from '@angular/core'\r\nfunction test (x: Array\u003cany> | QueryList\u003cany>) {\r\n return x.map(x => x)\r\n}\r\n```\r\n\r\n## 🌍 Your Environment\r\n\r\n**Angular Version:**\r\n\u003cpre>\u003ccode>\r\n\u003c!-- run `ng version` and paste output below -->\r\n\u003c!-- ✍️-->\r\n _ _ ____ _ ___\r\n / \\ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|\r\n / △ \\ | '_ \\ / _` | | | | |/ _` | '__| | | | | | |\r\n / ___ \\| | | | (_| | |_| | | (_| | | | |___| |___ | |\r\n /_/ \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_| \\____|_____|___|\r\n |___/\r\n \r\n\r\nAngular CLI: 10.0.5\r\nNode: 14.3.0\r\nOS: linux x64\r\n\r\nAngular: 10.0.7\r\n... animations, common, compiler, compiler-cli, core, forms\r\n... language-service, localize, platform-browser\r\n... platform-browser-dynamic, router\r\nIvy Workspace: Yes\r\n\r\nPackage Version\r\n-----------------------------------------------------------\r\n@angular-devkit/architect 0.1000.5\r\n@angular-devkit/build-angular 0.1000.5\r\n@angular-devkit/build-optimizer 0.1000.5\r\n@angular-devkit/build-webpack 0.1000.5\r\n@angular-devkit/core 10.0.5\r\n@angular-devkit/schematics 10.0.5\r\n@angular/cli 10.0.5\r\n@ngtools/webpack 10.0.5\r\n@schematics/angular 10.0.5\r\n@schematics/update 0.1000.5\r\nrxjs 6.5.5\r\ntypescript 3.9.7\r\nwebpack 4.43.0\r\n\r\n\u003c/code>\u003c/pre>\r\n\r\n**Anything else relevant?** No.\r\n\u003c!-- ✍️Is this a browser specific issue? If so, please specify the browser and version. -->\r\n\r\n\u003c!-- ✍️Do any of these matter: operating system, IDE, package manager, HTTP server, ...? If so, please mention it below. -->\r\n","author":{"url":"https://github.com/lazarljubenovic","@type":"Person","name":"lazarljubenovic"},"datePublished":"2020-11-07T21:12:29Z","url":"https://github.com/angular/angular/issues/39602"}
| 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:8849ed07-167f-4467-bde8-4249c5fd6643 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A256:19F84C:A8F4BF:DAC623:6B00E3D8 |
| html-safe-nonce | 94e4ec111004394140779bf9e48030a53fddf40cf2eec88efe4f3fbb29fada5d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjU2OjE5Rjg0QzpBOEY0QkY6REFDNjIzOjZCMDBFM0Q4IiwidmlzaXRvcl9pZCI6IjYyNDA5MzcxMDkzNzgwOTg4MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3de4e64c7365aca079f4e8eda78e22fcc53e1f20d901296bf6c2f9d50a09756a |
| hovercard-subject-tag | issue:738318855 |
| 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/angular/angular/39602/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fce6e96468735847463a1c9050f51b417f78128650a982222ffa6acc4cd980fb/angular/angular/issues/39602 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fce6e96468735847463a1c9050f51b417f78128650a982222ffa6acc4cd980fb/angular/angular/issues/39602 |
| og:image:alt | 🐞 bug report Affected Package The issue is caused by package @angular/core. Is this a regression? No. Description I have a function that I wish to work with both QueryList and Array. Both types hav... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lazarljubenovic |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| 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