Title: Mapped types on tuples and arrays not working recursively · Issue #29442 · microsoft/TypeScript · GitHub
Open Graph Title: Mapped types on tuples and arrays not working recursively · Issue #29442 · microsoft/TypeScript
X Title: Mapped types on tuples and arrays not working recursively · Issue #29442 · microsoft/TypeScript
Description: TypeScript Version: 3.2.2 (ts playground) Search Terms: recursive, mapped types, tuple, array Code type DeepMap
Open Graph Description: TypeScript Version: 3.2.2 (ts playground) Search Terms: recursive, mapped types, tuple, array Code type DeepMap
X Description: TypeScript Version: 3.2.2 (ts playground) Search Terms: recursive, mapped types, tuple, array Code type DeepMap<T extends unknown[], R> = { [K in keyof T]: T[K] extends unknown[] ? DeepMap<...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/29442
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Mapped types on tuples and arrays not working recursively","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 3.2.2 (ts playground)\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** recursive, mapped types, tuple, array\r\n\r\n**Code**\r\n\r\n```ts\r\ntype DeepMap\u003cT extends unknown[], R> = {\r\n [K in keyof T]: T[K] extends unknown[] ? DeepMap\u003cT[K], R> : R;\r\n};\r\n\r\ntype tup = [string, [string, [string]]];\r\ntype arr = string[][];\r\n\r\ntype t1 = DeepMap\u003ctup, number>;\r\ntype t2 = DeepMap\u003carr, number>;\r\n```\r\n\r\n**Expected behavior:**\r\n```ts\r\ntype t1 = [number, [number, [number]]];\r\ntype t2 = number[][];\r\n```\r\n\r\n**Actual behavior:**\r\n```ts\r\ntype t1 = [number, any];\r\ntype t2 = any[];\r\n```\r\n\r\n[**Playground Link:**](https://www.typescriptlang.org/play/index.html#src=type%20DeepMap%3CT%20extends%20unknown%5B%5D%2C%20R%3E%20%3D%20%7B%0D%0A%20%20%5BK%20in%20keyof%20T%5D%3A%20T%5BK%5D%20extends%20unknown%5B%5D%20%3F%20DeepMap%3CT%5BK%5D%2C%20R%3E%20%3A%20R%3B%0D%0A%7D%3B%0D%0A%0D%0Atype%20tup%20%3D%20%5Bstring%2C%20%5Bstring%2C%20%5Bstring%5D%5D%5D%3B%0D%0Atype%20arr%20%3D%20string%5B%5D%5B%5D%3B%0D%0A%0D%0Atype%20t1%20%3D%20DeepMap%3Ctup%2C%20number%3E%3B%20%2F%2F%20%5Bnumber%2C%20any%5D%20inferred%0D%0Atype%20t2%20%3D%20DeepMap%3Carr%2C%20number%3E%3B%20%2F%2F%20any%5B%5D%20inferred%0D%0A)\r\n\u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior -->\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n","author":{"url":"https://github.com/Voronar","@type":"Person","name":"Voronar"},"datePublished":"2019-01-16T12:22:14Z","url":"https://github.com/microsoft/TypeScript/issues/29442"}
| 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:17c96739-b28b-cac1-e4a4-c436a1d05154 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6AA:7C021:45FB5:614E7:6B04A301 |
| html-safe-nonce | b9615d070b0b19816b90a0b608b6aad2bc87acf05344ce88acb44990bdb2abf3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkFBOjdDMDIxOjQ1RkI1OjYxNEU3OjZCMDRBMzAxIiwidmlzaXRvcl9pZCI6IjI1Nzg0Mzk2NzE4NDM2OTMzMTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d8b18c7ce0f1fe0f0b021ed750076edde3194387d7457d3faf1858d71083005e |
| hovercard-subject-tag | issue:399784594 |
| 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/29442/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b54cb6768f737a13611fabbee5fb0fcc2ee05a8d2e477d6c7da92caa32712dfc/microsoft/TypeScript/issues/29442 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b54cb6768f737a13611fabbee5fb0fcc2ee05a8d2e477d6c7da92caa32712dfc/microsoft/TypeScript/issues/29442 |
| og:image:alt | TypeScript Version: 3.2.2 (ts playground) Search Terms: recursive, mapped types, tuple, array Code type DeepMap |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Voronar |
| hostname | github.com |
| expected-hostname | github.com |
| None | 188497a0f45a7aa8f7c866faa1950d1a7f8d82b59416adf549b222ad1d1dd19b |
| 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 | 557cfbac6cdb532730c95c90f2cefdc0c4128029 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width