Title: Recursive type definitions regression in 3.4.0 · Issue #30841 · microsoft/TypeScript · GitHub
Open Graph Title: Recursive type definitions regression in 3.4.0 · Issue #30841 · microsoft/TypeScript
X Title: Recursive type definitions regression in 3.4.0 · Issue #30841 · microsoft/TypeScript
Description: TypeScript Version: 3.4.0-dev.201xxxxx Search Terms: Recursive Conditional Code type Action< Args extends any[], Payload extends Record
Open Graph Description: TypeScript Version: 3.4.0-dev.201xxxxx Search Terms: Recursive Conditional Code type Action< Args extends any[], Payload extends Record
X Description: TypeScript Version: 3.4.0-dev.201xxxxx Search Terms: Recursive Conditional Code type Action< Args extends any[], Payload extends Record<string, any>, T extends string > = ((...args: Arg...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/30841
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Recursive type definitions regression in 3.4.0","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--\u003e\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. --\u003e\r\n**TypeScript Version:** 3.4.0-dev.201xxxxx\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\nRecursive\r\nConditional\r\n\r\n**Code**\r\n\r\n```ts\r\ntype Action\u003c\r\n Args extends any[],\r\n Payload extends Record\u003cstring, any\u003e,\r\n T extends string\r\n\u003e = ((...args: Args) =\u003e (Payload \u0026 { type: T })) \u0026 {\r\n readonly type: T\r\n}\r\n\r\ntype AnyAction = Action\u003cany[], any, string\u003e\r\n\r\ntype CascadingActionMap = {\r\n [name: string]: AnyAction | CascadingActionMap\r\n}\r\n\r\ntype Reducer\u003cS, T\u003e = (state: S, action: T) =\u003e S\r\n\r\ntype CascadingActionType\u003cT\u003e = T extends CascadingActionMap\r\n ? { [K in keyof T]: ActionType\u003cT[K]\u003e }[keyof T]\r\n : never\r\n\r\nexport type ActionType\u003cT\u003e = T extends AnyAction\r\n ? ReturnType\u003cT\u003e\r\n : T extends Reducer\u003cany, infer A\u003e\r\n ? A\r\n : CascadingActionType\u003cT\u003e\r\n```\r\n\r\n**Expected behavior:**\r\nNo errors. It's worth noting that it works in 3.3.4, with the correct derived type.\r\n\r\n**Actual behavior:**\r\nRunning `tsc` command line, it reports the following errors:\r\n\r\n```\r\nerror TS2456: Type alias 'CascadingActionType' circularly references itself.\r\n\r\n914 type CascadingActionType\u003cT\u003e = T extends CascadingActionMap\r\n ~~~~~~~~~~~~~~~~~~~\r\n\r\nerror TS2315: Type 'ActionType' is not generic.\r\n\r\n915 ? { [K in keyof T]: ActionType\u003cT[K]\u003e }[keyof T]\r\n ~~~~~~~~~~~~~~~~\r\n\r\nerror TS2456: Type alias 'ActionType' circularly references itself.\r\n\r\n918 export type ActionType\u003cT\u003e = T extends AnyAction\r\n ~~~~~~~~~~\r\n\r\nerror TS2315: Type 'CascadingActionType' is not generic.\r\n\r\n924 : CascadingActionType\u003cT\u003e\r\n ~~~~~~~~~~~~~~~~~~~~~~\r\n```\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior --\u003e\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? --\u003e\r\n","author":{"url":"https://github.com/TerenceZ","@type":"Person","name":"TerenceZ"},"datePublished":"2019-04-10T02:15:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/30841/TypeScript/issues/30841"}
| 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:e7844721-cde1-6a56-483d-4b6dc009f904 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 98E4:9372F:6131B:8BA82:6A6211A8 |
| html-safe-nonce | fa3a0baf5edc213f7e9b2112c0a046c88df2fc53ce31e1dd7425d81b05a91ec5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OEU0OjkzNzJGOjYxMzFCOjhCQTgyOjZBNjIxMUE4IiwidmlzaXRvcl9pZCI6IjI0OTM0MTk1MjcxOTMzNjY5NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f6ab06559f269f2b7a69ba04abe16ae1b13a83b12cda91fc9a8f8034afeb5922 |
| hovercard-subject-tag | issue:431272245 |
| 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/30841/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8db38590e36fad3b87122768e33a8323743d60eb480a01682a2c2660f25f974c/microsoft/TypeScript/issues/30841 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8db38590e36fad3b87122768e33a8323743d60eb480a01682a2c2660f25f974c/microsoft/TypeScript/issues/30841 |
| og:image:alt | TypeScript Version: 3.4.0-dev.201xxxxx Search Terms: Recursive Conditional Code type Action< Args extends any[], Payload extends Record |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | TerenceZ |
| hostname | github.com |
| expected-hostname | github.com |
| None | be9a4d9589756e22b427637ffbf1123a96e067050e57f5cec403e3080a650ca4 |
| 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 | 7b5509702f01f876c214a2cbb142690847de0019 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width