Title: Regression in 2.9+: conditional type inferring empty object · Issue #24784 · microsoft/TypeScript · GitHub
Open Graph Title: Regression in 2.9+: conditional type inferring empty object · Issue #24784 · microsoft/TypeScript
X Title: Regression in 2.9+: conditional type inferring empty object · Issue #24784 · microsoft/TypeScript
Description: TypeScript Version: 3.0.0-dev.20180607 Search Terms: conditional inference empty infer extends mapped Code type Combine
Open Graph Description: TypeScript Version: 3.0.0-dev.20180607 Search Terms: conditional inference empty infer extends mapped Code type Combine
X Description: TypeScript Version: 3.0.0-dev.20180607 Search Terms: conditional inference empty infer extends mapped Code type Combine<C, Prop extends string> = { [Key in keyof C]: ( C[Key] extends { [X in ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/24784
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression in 2.9+: conditional type inferring empty object","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.0.0-dev.20180607\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** \r\n\r\nconditional inference empty infer extends mapped\r\n\r\n**Code**\r\n\r\n```ts\r\ntype Combine\u003cC, Prop extends string> = {\r\n [Key in keyof C]: (\r\n C[Key] extends { [X in Prop]: infer Just } ? Just :\r\n C[Key] extends { [X in Prop]?: infer Maybe } ? (Maybe | undefined) :\r\n undefined\r\n )\r\n}\r\n\r\ntype Test = {\r\n x: {\r\n test?: boolean,\r\n },\r\n y: {\r\n test?: boolean,\r\n },\r\n}\r\n\r\ntype Combined = Combine\u003cTest, 'test'>\r\n\r\nlet combined: Combined\r\n\r\n// Type '{}' is not assignable to type 'boolean'.\r\nlet flag: boolean = combined.x\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nShould compile, as the type of `combined.x` should be boolean.\r\n\r\n**Actual behavior:**\r\n\r\nIn 2.9+, fails with \"Type '{}' is not assignable to type 'boolean'.\"\r\n\r\nIn 2.8.1, compiles without error.\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior --> \r\n\r\n[Playground link](https://www.typescriptlang.org/play/index.html#src=type%20Combine%3CC%2C%20Prop%20extends%20string%3E%20%3D%20%7B%0D%0A%20%20%5BKey%20in%20keyof%20C%5D%3A%20(%0D%0A%20%20%20%20C%5BKey%5D%20extends%20%7B%20%5BX%20in%20Prop%5D%3A%20infer%20Just%20%7D%20%3F%20Just%20%3A%0D%0A%20%20%20%20C%5BKey%5D%20extends%20%7B%20%5BX%20in%20Prop%5D%3F%3A%20infer%20Maybe%20%7D%20%3F%20(Maybe%20%7C%20undefined)%20%3A%0D%0A%20%20%20%20undefined%0D%0A%20%20)%0D%0A%7D%0D%0A%0D%0Atype%20Test%20%3D%20%7B%0D%0A%20%20x%3A%20%7B%0D%0A%20%20%20%20test%3F%3A%20boolean%2C%0D%0A%20%20%7D%2C%0D%0A%20%20y%3A%20%7B%0D%0A%20%20%20%20test%3F%3A%20boolean%2C%0D%0A%20%20%7D%2C%0D%0A%7D%0D%0A%0D%0Atype%20Combined%20%3D%20Combine%3CTest%2C%20'test'%3E%0D%0A%0D%0Alet%20combined%3A%20Combined%0D%0A%0D%0A%2F%2F%20Type%20'%7B%7D'%20is%20not%20assignable%20to%20type%20'boolean'.%0D%0Alet%20flag%3A%20boolean%20%3D%20combined.x)\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n\r\n- https://github.com/Microsoft/TypeScript/issues/24640","author":{"url":"https://github.com/jamesknelson","@type":"Person","name":"jamesknelson"},"datePublished":"2018-06-08T03:25:22Z","url":"https://github.com/microsoft/TypeScript/issues/24784"}
| 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:9d4d6a9f-33fa-463d-51e5-cfc9275bb81b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE94:FC5BE:27A802E:34AB814:6B01AD24 |
| html-safe-nonce | 1fff61875ddd87d902148bb030af772429a08a72cc8b3703e76bae40267403ef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTk0OkZDNUJFOjI3QTgwMkU6MzRBQjgxNDo2QjAxQUQyNCIsInZpc2l0b3JfaWQiOiI4NjgyMDMzMjMxMDg1ODA4OTMyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3f48969bde87d6daf964011ccacc7d301dd09550c5e0dad48b3b97c904e590e8 |
| hovercard-subject-tag | issue:330506521 |
| 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/24784/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e2986566f6368b048c86e490ebbfed71c387be4d7551d7f9e007436d299d2815/microsoft/TypeScript/issues/24784 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e2986566f6368b048c86e490ebbfed71c387be4d7551d7f9e007436d299d2815/microsoft/TypeScript/issues/24784 |
| og:image:alt | TypeScript Version: 3.0.0-dev.20180607 Search Terms: conditional inference empty infer extends mapped Code type Combine |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jamesknelson |
| 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