Title: mapping over an array of tuple types does not give the correct type · Issue #11312 · microsoft/TypeScript · GitHub
Open Graph Title: mapping over an array of tuple types does not give the correct type · Issue #11312 · microsoft/TypeScript
X Title: mapping over an array of tuple types does not give the correct type · Issue #11312 · microsoft/TypeScript
Description: TypeScript Version: 2.0.3 Code The map callback in the code below is the identity function. let arr: Array<[number, number]> = [[1, 2]] let mappedArr: Array<[number, number]> = arr.map(([x, y]) => { return [x, y]; }) Expected behavior: m...
Open Graph Description: TypeScript Version: 2.0.3 Code The map callback in the code below is the identity function. let arr: Array<[number, number]> = [[1, 2]] let mappedArr: Array<[number, number]> = arr.map(([x, y]) => ...
X Description: TypeScript Version: 2.0.3 Code The map callback in the code below is the identity function. let arr: Array<[number, number]> = [[1, 2]] let mappedArr: Array<[number, number]> = arr.map(...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/11312
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mapping over an array of tuple types does not give the correct type","articleBody":"\u003c!-- BUGS: Please use this template. -->\n\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\n\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\n\n**TypeScript Version:** 2.0.3\n\n**Code**\n\nThe `map` callback in the code below is the identity function.\n\n``` ts\nlet arr: Array\u003c[number, number]> = [[1, 2]]\n\nlet mappedArr: Array\u003c[number, number]> = arr.map(([x, y]) => {\n return [x, y];\n})\n```\n\n**Expected behavior:** `mappedArr` is of type `Array\u003c[number, number]>`. Compilation works.\n\n**Actual behavior:** Doesn't work. Error message:\n\n```\nType 'number[][]' is not assignable to type '[number, number][]'.\n Type 'number[]' is not assignable to type '[number, number]'.\n Property '0' is missing in type 'number[]'.\n```\n\n [TypeScript playground link](https://www.typescriptlang.org/play/#src=let%20arr%3A%20Array%3C%5Bnumber%2C%20number%5D%3E%20%3D%20%5B%5B1%2C%202%5D%5D%0D%0A%0D%0Alet%20mappedArr%3A%20Array%3C%5Bnumber%2C%20number%5D%3E%20%3D%20arr.map%28%28%5Bx%2C%20y%5D%29%20%3D%3E%20%7B%0D%0A%20%20%20%20return%20%5Bx%2C%20y%5D%3B%0D%0A%7D%29%0D%0A)\n","author":{"url":"https://github.com/mattyork","@type":"Person","name":"mattyork"},"datePublished":"2016-10-03T03:03:07Z","url":"https://github.com/microsoft/TypeScript/issues/11312"}
| 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:6b7857ba-d6c3-049a-0703-fa629f435eae |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EADE:19AA62:B087ED:E1C7B4:6B00F743 |
| html-safe-nonce | 753aa7c86516c7da8bb701a9c78916f9c9d9547f02a70db0e26c290e936ce2c4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQURFOjE5QUE2MjpCMDg3RUQ6RTFDN0I0OjZCMDBGNzQzIiwidmlzaXRvcl9pZCI6IjY2MTE1ODkwNjQzMDkxNDMzNjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8d337906f230424379d14e83889b428c417325351456cdf4184ac20cb7ee5724 |
| hovercard-subject-tag | issue:180555204 |
| 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/11312/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c0abb7d9d0b1b00bb9003813127c545f45bbc2ff9b7c9d0eff247e8e50ad7668/microsoft/TypeScript/issues/11312 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c0abb7d9d0b1b00bb9003813127c545f45bbc2ff9b7c9d0eff247e8e50ad7668/microsoft/TypeScript/issues/11312 |
| og:image:alt | TypeScript Version: 2.0.3 Code The map callback in the code below is the identity function. let arr: Array<[number, number]> = [[1, 2]] let mappedArr: Array<[number, number]> = arr.map(([x, y]) => ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mattyork |
| 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