Title: 3.5.1 regression in mapped types on tuples · Issue #31736 · microsoft/TypeScript · GitHub
Open Graph Title: 3.5.1 regression in mapped types on tuples · Issue #31736 · microsoft/TypeScript
X Title: 3.5.1 regression in mapped types on tuples · Issue #31736 · microsoft/TypeScript
Description: TypeScript Version: 3.5.1 Search Terms: regression, mapped types, tuples Code type Model
Open Graph Description: TypeScript Version: 3.5.1 Search Terms: regression, mapped types, tuples Code type Model
X Description: TypeScript Version: 3.5.1 Search Terms: regression, mapped types, tuples Code type Model<TProps = any> = { props: TProps; }; type ExtractModelProps<TModel extends Model> = TModel extend...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/31736
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"3.5.1 regression in mapped types on tuples","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.5.1\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** regression, mapped types, tuples\r\n\r\n**Code**\r\n\r\n```ts\r\ntype Model\u003cTProps = any> = {\r\n props: TProps;\r\n};\r\n\r\ntype ExtractModelProps\u003cTModel extends Model> = TModel extends Model\u003c\r\n infer TProps\r\n>\r\n ? TProps\r\n : never;\r\n\r\ntype Options\u003cTType extends string = string, TModel extends Model = Model> = {\r\n type: TType;\r\n getModel: () => TModel;\r\n};\r\n\r\ntype ExtractPropsListFromOptionsList\u003cTOptionsList extends Options[]> = {\r\n [P in keyof TOptionsList]: TOptionsList[P] extends Options\r\n ? ExtractModelProps\u003cReturnType\u003cTOptionsList[P][\"getModel\"]>>\r\n : never\r\n};\r\n\r\n// expected: [string, number]\r\ntype PropsList = ExtractPropsListFromOptionsList\u003c[\r\n {\r\n type: 'foo',\r\n getModel: () => {\r\n props: string\r\n }\r\n },\r\n {\r\n type: 'bar',\r\n getModel: () => {\r\n props: number\r\n }\r\n }\r\n]>;\r\n```\r\n\r\n**Expected behavior:**\r\n`PropsList` should be `[string, number]`, no error emitted.\r\n\r\n**Actual behavior:**\r\nIn 3.4.5, it works as expected.\r\nIn 3.5.1, it emits errors at `ExtractModelProps\u003cReturnType\u003cTOptionsList[P][\"getModel\"]>>`:\r\n```\r\nType 'ReturnType\u003cTOptionsList[P][\"getModel\"]>' does not satisfy the constraint 'Model\u003cany>'.\r\n Type 'unknown' is not assignable to type 'Model\u003cany>'.\r\n Type 'ReturnType\u003cTOptionsList[keyof TOptionsList][\"getModel\"]>' is not assignable to type 'Model\u003cany>'.\r\n Type 'unknown' is not assignable to type 'Model\u003cany>'.\r\n Type 'ReturnType\u003cTOptionsList[string | number | symbol][\"getModel\"]>' is not assignable to type 'Model\u003cany>'.\r\n Type 'unknown' is not assignable to type 'Model\u003cany>'.\r\n Type 'ReturnType\u003cTOptionsList[string][\"getModel\"]> | ReturnType\u003cTOptionsList[number][\"getModel\"]> | ReturnType\u003cTOptionsList[symbol][\"getModel\"]>' is not assignable to type 'Model\u003cany>'.\r\n Type 'ReturnType\u003cTOptionsList[string][\"getModel\"]>' is not assignable to type 'Model\u003cany>'.\r\n Type 'unknown' is not assignable to type 'Model\u003cany>'.ts(2344)\r\n```\r\n\r\nIf I change `TOptionsList[P] extends Options` to `P extends number`, it won't emit errors. But the result of `PropsList` is `[never, never]`.\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior -->\r\nhttps://www.typescriptlang.org/play/index.html#src=type%20Model%3CTProps%20%3D%20any%3E%20%3D%20%7B%0D%0A%20%20%20%20props%3A%20TProps%3B%0D%0A%7D%3B%0D%0A%0D%0Atype%20ExtractModelProps%3CTModel%20extends%20Model%3E%20%3D%20TModel%20extends%20Model%3C%0D%0A%20%20%20%20infer%20TProps%0D%0A%3E%0D%0A%20%20%20%20%3F%20TProps%0D%0A%20%20%20%20%3A%20never%3B%0D%0A%0D%0Atype%20Options%3CTType%20extends%20string%20%3D%20string%2C%20TModel%20extends%20Model%20%3D%20Model%3E%20%3D%20%7B%0D%0A%20%20%20%20type%3A%20TType%3B%0D%0A%20%20%20%20getModel%3A%20()%20%3D%3E%20TModel%3B%0D%0A%7D%3B%0D%0A%0D%0Atype%20ExtractPropsListFromOptionsList%3CTOptionsList%20extends%20Options%5B%5D%3E%20%3D%20%7B%0D%0A%20%20%20%20%5BP%20in%20keyof%20TOptionsList%5D%3A%20TOptionsList%5BP%5D%20extends%20Options%0D%0A%20%20%20%20%3F%20ExtractModelProps%3CReturnType%3CTOptionsList%5BP%5D%5B%22getModel%22%5D%3E%3E%0D%0A%20%20%20%20%3A%20never%0D%0A%7D%3B%0D%0A%0D%0A%2F%2F%20expected%3A%20%5Bstring%2C%20number%5D%0D%0Atype%20PropsList%20%3D%20ExtractPropsListFromOptionsList%3C%5B%0D%0A%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20type%3A%20'foo'%2C%0D%0A%20%20%20%20%20%20%20%20getModel%3A%20()%20%3D%3E%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20props%3A%20string%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%7D%2C%0D%0A%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20type%3A%20'bar'%2C%0D%0A%20%20%20%20%20%20%20%20getModel%3A%20()%20%3D%3E%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20props%3A%20number%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%7D%0D%0A%5D%3E%3B%0D%0A\r\n\r\nSeems the version of Playground is not 3.5.1 for now.\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n","author":{"url":"https://github.com/SpringNyan","@type":"Person","name":"SpringNyan"},"datePublished":"2019-06-03T10:45:18Z","url":"https://github.com/microsoft/TypeScript/issues/31736"}
| 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:e4519707-1a5d-b364-40f6-9a9755f8784d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C842:B1B84:23BCF96:2D725A0:6B01BE7F |
| html-safe-nonce | 2dce89e7abc24bede5faebea7c1f8371764ce2144f7801b3df2359fb7ce99f21 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODQyOkIxQjg0OjIzQkNGOTY6MkQ3MjVBMDo2QjAxQkU3RiIsInZpc2l0b3JfaWQiOiI4ODQ2NTc5ODc0OTQxNDg0NjcyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | bb9dc46d2435f1e2cee3e1ac40212cce4650b37e371edd35fa4ffeb92d21bd12 |
| hovercard-subject-tag | issue:451413693 |
| 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/31736/issue_layout |
| twitter:image | https://opengraph.githubassets.com/18c6303478145a40461b387bf0e1450cfccad34af4d271a584d1bb8650028ec2/microsoft/TypeScript/issues/31736 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/18c6303478145a40461b387bf0e1450cfccad34af4d271a584d1bb8650028ec2/microsoft/TypeScript/issues/31736 |
| og:image:alt | TypeScript Version: 3.5.1 Search Terms: regression, mapped types, tuples Code type Model |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SpringNyan |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width