Title: Regression: Mapped type with recursive key remapping crashes tsc with "RangeError: Maximum call stack size exceeded" in TS@5.4+ · Issue #60476 · microsoft/TypeScript · GitHub
Open Graph Title: Regression: Mapped type with recursive key remapping crashes tsc with "RangeError: Maximum call stack size exceeded" in TS@5.4+ · Issue #60476 · microsoft/TypeScript
X Title: Regression: Mapped type with recursive key remapping crashes tsc with "RangeError: Maximum call stack size exceeded" in TS@5.4+ · Issue #60476 · microsoft/TypeScript
Description: 🔎 Search Terms "Mapped type", "Recursive mapped type", "Recursive type", "RangeError: maximum call stack size exceeded" 🕗 Version & Regression Information This changed between versions 5.3.3 and 5.4.5 ⏯ Playground Link https://www.typesc...
Open Graph Description: 🔎 Search Terms "Mapped type", "Recursive mapped type", "Recursive type", "RangeError: maximum call stack size exceeded" 🕗 Version & Regression Information This changed between versions 5.3.3 and 5....
X Description: 🔎 Search Terms "Mapped type", "Recursive mapped type", "Recursive type", "RangeError: maximum call stack size exceeded" 🕗 Version & Regression Informatio...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/60476
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression: Mapped type with recursive key remapping crashes tsc with \"RangeError: Maximum call stack size exceeded\" in TS@5.4+","articleBody":"### 🔎 Search Terms\n\n\"Mapped type\", \"Recursive mapped type\", \"Recursive type\", \"RangeError: maximum call stack size exceeded\"\n\n### 🕗 Version & Regression Information\n\n- This changed between versions 5.3.3 and 5.4.5\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?ts=5.4.5#code/KYDwDg9gTgLgBDAnmYcBiAbAhjGwB2AKssADwDKEArlAMaqh74AmAznBAEYBWwtMAGjiEsUAObAYAPjgBeOAG8AUHDgBtANLBEcAJb44Aa20QAZnEo16cLOy07GBNnFYwo+sStVwA-Bep0wJraALpwjizsXLz8Xt6+cAAGACQK9gC+AHSpxohm6Ni4BMQoFAH0wYghQiLikjIAZC5uHumJcd4AXHD2Hd34wABuwFAhALQ+3bUSMADcSunzSkgo6LrAGMzkG3zw8sqqMFicGMDdru74YvOqpuub5y1X8+lKyyRwAILMzFDArOx9l5IK4AMIQZhnZqXa5eSGsWjuMAwXQQfCPGE3Gw-P4AjEeF5vFaoACqrBGckUXl0zH6VAAtpwRlj8Fh6VCLgSvFgcf9WN1vr8+YT3qtMDgmMBmGSKfJxUUiCRSDKoEI0Pctjt+FJ5gB6XXxQ0APR8QA\n\n### 💻 Code\n\n```ts\nexport type FlattenType\u003cSource extends object, Target> = {\n [Key in keyof Source as Key extends string\n ? Source[Key] extends object\n ? `${Key}.${keyof FlattenType\u003cSource[Key], Target> & string}`\n : Key\n : never]-?: Target;\n};\n\ntype FieldSelect = {\n table: string;\n field: string;\n}\n\ntype Address = {\n postCode: string;\n description: string;\n address: string;\n}\n\ntype User = {\n id: number;\n name: string;\n address: Address;\n}\n\ntype FlattenedUser = FlattenType\u003cUser, FieldSelect>;\n// ^?\n```\n\n\n### 🙁 Actual behavior\n\nCompilation crashes with \"RangeError: maximum call stack size exceeded\"\n\n### 🙂 Expected behavior\n\nNo crash with the type working correctly or explicit error on the recursive type like \"Type instantiation is excessively deep and possibly infinite. ts(2589)\"\n\n### Additional information about the issue\n\nSame playground in version 5.3.3 where the type resolves with no crash\nhttps://www.typescriptlang.org/play/?ts=5.3.3#code/KYDwDg9gTgLgBDAnmYcBiAbAhjGwB2AKssADwDKEArlAMaqh74AmAznBAEYBWwtMAGjiEsUAObAYAPjgBeOAG8AUHDgBtANLBEcAJb44Aa20QAZnEo16cLOy07GBNnFYwo+sStVwA-Bep0wJraALpwjizsXLz8Xt6+cAAGACQK9gC+AHSpxohm6Ni4BMQoFAH0wYghQiLikjIAZC5uHumJcd4AXHD2Hd34wABuwFAhALQ+3bUSMADcSunzSkgo6LrAGMzkG3zw8sqqMFicGMDdru74YvOqpuub5y1X8+lKyyRwAILMzFDArOx9l5IK4AMIQZhnZqXa5eSGsWjuMAwXQQfCPGE3Gw-P4AjEeF5vFaoACqrBGckUXl0zH6VAAtpwRlj8Fh6VCLgSvFgcf9WN1vr8+YT3qtMDgmMBmGSKfJxUUiCRSDKoEI0Pctjt+FJ5gB6XXxQ0APR8QA\n\nWe ran into this crash when upgrading the ts version in our project.\n\nThere's a workaround based on the approach described in https://blog.swmansion.com/deep-flatten-typescript-type-c0d123028d82 which doesn't cause a crash on these versions.\n\nThe original type that caused the crash has mostly the same motivation as the blog post above. The provided snippet was simplified to a minimal reproducible example.","author":{"url":"https://github.com/nking07049925","@type":"Person","name":"nking07049925"},"datePublished":"2024-11-11T14:19:13Z","url":"https://github.com/microsoft/TypeScript/issues/60476"}
| 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:28739156-cfa0-383f-e1d0-43ba173f61fc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B100:4BB79:25A84C0:3017495:6B0197BC |
| html-safe-nonce | 4ddb9f26768f99829040be8d31584ada7fe91b162e9748a72f7f16626018daa0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTAwOjRCQjc5OjI1QTg0QzA6MzAxNzQ5NTo2QjAxOTdCQyIsInZpc2l0b3JfaWQiOiIzNDEwNDc2OTY3MTA2MDI1NDA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 35581a79395272b6e28563bf0f746e3a1ef6d0c8333ff48ca7e9df20079e1b9d |
| hovercard-subject-tag | issue:2649470844 |
| 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/60476/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5bdae3f80e531d5c9aa5038baa09631d534bf3aae62902b6e39aacc237f2cb7c/microsoft/TypeScript/issues/60476 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5bdae3f80e531d5c9aa5038baa09631d534bf3aae62902b6e39aacc237f2cb7c/microsoft/TypeScript/issues/60476 |
| og:image:alt | 🔎 Search Terms "Mapped type", "Recursive mapped type", "Recursive type", "RangeError: maximum call stack size exceeded" 🕗 Version & Regression Information This changed between versions 5.3.3 and 5.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nking07049925 |
| 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