Title: map on tuples with more than 5 elements · Issue #13840 · microsoft/TypeScript · GitHub
Open Graph Title: map on tuples with more than 5 elements · Issue #13840 · microsoft/TypeScript
X Title: map on tuples with more than 5 elements · Issue #13840 · microsoft/TypeScript
Description: TypeScript Version: 2.1.1 Code const a: [number, number, number, number, number, number] = [1,2,3,4,5,6]; const b = a.map(x => x) Expected behavior: b should have the same type as a, i.e. a tuple of 6 numbers Actual behavior: b has the t...
Open Graph Description: TypeScript Version: 2.1.1 Code const a: [number, number, number, number, number, number] = [1,2,3,4,5,6]; const b = a.map(x => x) Expected behavior: b should have the same type as a, i.e. a tuple o...
X Description: TypeScript Version: 2.1.1 Code const a: [number, number, number, number, number, number] = [1,2,3,4,5,6]; const b = a.map(x => x) Expected behavior: b should have the same type as a, i.e. a tupl...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/13840
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"map on tuples with more than 5 elements","articleBody":"**TypeScript Version:** 2.1.1\r\n\r\n**Code**\r\n\r\n```ts\r\nconst a: [number, number, number, number, number, number] = [1,2,3,4,5,6];\r\nconst b = a.map(x => x)\r\n\r\n```\r\n\r\n**Expected behavior:**\r\n`b` should have the same type as `a`, i.e. a tuple of 6 `number`s\r\n**Actual behavior:**\r\n`b` has the type of a tuple of 5 `number`s. Not only is this unexpected, it also doesn't match what happens at runtime where `b.length == a.length` as expected.\r\n\r\nIt seems to me that the problem comes from the tuple overloads of `map` added in https://github.com/Microsoft/TypeScript/pull/11252.\r\nIf I understand this correctly, https://github.com/Microsoft/TypeScript/issues/5453 would be needed in order to these overloads correctly for the general case.\r\nIn the meantime if there was some way of falling back to an array for map on longer tuples, that would work, e.g. adding an overload like this maybe?\r\n```ts\r\nmap\u003cQ extends [T, T, T, T, T, T], U>(this: Q, callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[];\r\n```","author":{"url":"https://github.com/John-Colvin","@type":"Person","name":"John-Colvin"},"datePublished":"2017-02-02T15:10:36Z","url":"https://github.com/microsoft/TypeScript/issues/13840"}
| 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:9c113c5a-b13f-8b6b-5598-e2b6b6a09be7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D5A0:6365:B57B98:F3641F:6B00F592 |
| html-safe-nonce | e2a991f1735cee587dfdcac04014f92746874829f02a2bde185d9321c8ebd243 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENUEwOjYzNjU6QjU3Qjk4OkYzNjQxRjo2QjAwRjU5MiIsInZpc2l0b3JfaWQiOiI4NjQyNTY4MzI3MDg2MDExNzk0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 958ecf75e62d5f6badb30e68581064c6ccfdb0d85a2b9ee72bb13e35ec522a1b |
| hovercard-subject-tag | issue:204900837 |
| 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/13840/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1683412affce56a9b3873934865776d371e3f2935feda260b50dfe275b15c852/microsoft/TypeScript/issues/13840 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1683412affce56a9b3873934865776d371e3f2935feda260b50dfe275b15c852/microsoft/TypeScript/issues/13840 |
| og:image:alt | TypeScript Version: 2.1.1 Code const a: [number, number, number, number, number, number] = [1,2,3,4,5,6]; const b = a.map(x => x) Expected behavior: b should have the same type as a, i.e. a tuple o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | John-Colvin |
| 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