Title: Issue · GitHub
Open Graph Title: Issue · microsoft/TypeScript
X Title: Issue · microsoft/TypeScript
Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Issue · microsoft/TypeScript
Open Graph Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Issue · microsoft/TypeScript
X Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Issue · microsoft/TypeScript
Opengraph URL: https://github.com/microsoft/TypeScript
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Can't dereference array type in conditional type","articleBody":"\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. --\u003e\r\n**TypeScript Version:** 2.8.1 and 2.9.0-dev.20180329\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) --\u003e\r\n**Search Terms:** \r\n\r\nI tried actually a **lot** of terms around mapped types, arrays, conditional types, array member dereferencing in mapped types etc..\r\n\r\n**Code**\r\n\r\n```ts\r\nexport type RecursivePartial\u003cT\u003e = {\r\n [P in keyof T]?: T[P] extends Array\u003cany\u003e ? {[index: number]: RecursivePartial\u003cT[P][0]\u003e} :\r\n T[P] extends object ? RecursivePartial\u003cT[P]\u003e : T[P];\r\n};\r\n\r\nvar a = {o: 1, b: 2, c: [{a: 1, c: '213'}]}\r\nfunction assign\u003cT\u003e(o: T, a: RecursivePartial\u003cT\u003e) { }\r\nassign(a, {o: 2, c: {0: {a: 2, c: '213123'}}})\r\n```\r\n\r\n**Expected behavior:**\r\n\r\n`T[P][0]` is usable and doesn't produce an error, since T[P] extends any[] and should thus be indexable on [0] (it seems this is the way to dereference an array)\r\n\r\n**Actual behavior:**\r\nI am getting `type 0 cannot be used to index type T[P]`.\r\n\r\nThe odd part is that behaviour-wise it seems to be working ! I can't change the type of the nested `c` to anything other than string and I can't create random properties or what.\r\n\r\nAm I missing something ?\r\n","author":{"url":"https://github.com/ceymard","@type":"Person","name":"ceymard"},"datePublished":"2018-03-29T15:45:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/22985/TypeScript/issues/22985"}
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:149e8f0a-b9ca-e633-845d-98f25eaa4e22 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C2BC:112899:310F35B:325C765:6A632232 |
| html-safe-nonce | 427d7446a5bf08fa8cc6d5e8cfb71f98eb8a365bb642eca5aa532ffb62c87bbf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkJDOjExMjg5OTozMTBGMzVCOjMyNUM3NjU6NkE2MzIyMzIiLCJ2aXNpdG9yX2lkIjoiNDM2MDg1NzkwNzE5NjI3MzIwMiIsInJlZ2lvbl9lZGdlIjoic2VhIiwicmVnaW9uX3JlbmRlciI6InNlYSJ9 |
| visitor-hmac | c1f9a0e601ff7378416ed1d415396f59808f7332c65e22ab35b0246da3033cfd |
| hovercard-subject-tag | repository:20929025 |
| 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/microsoft/TypeScript/issues/22985 |
| twitter:image | https://opengraph.githubassets.com/32df83b577a151f8ebebff8d664e0b17771da37297947b4d30b0bc06c450af47/microsoft/TypeScript |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/32df83b577a151f8ebebff8d664e0b17771da37297947b4d30b0bc06c450af47/microsoft/TypeScript |
| og:image:alt | TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Issue · microsoft/TypeScript |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1a6c056e02f174fffc096c521ec0ff6fb83e40a2ec8cb8875466ec1524872dd6 |
| turbo-cache-control | no-cache |
| 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 | 6a93e25585f487ddff9e3996c06d5b869d6e1828 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width