Title: Resolution order dependent circular heritage · Issue #61711 · microsoft/TypeScript · GitHub
Open Graph Title: Resolution order dependent circular heritage · Issue #61711 · microsoft/TypeScript
X Title: Resolution order dependent circular heritage · Issue #61711 · microsoft/TypeScript
Description: 🔎 Search Terms resolution order dependent circular heritage, circular base type, circular mixin 🕗 Version & Regression Information This changed in #39675 However, it appears this PR was the first time that circular heritage was (consiste...
Open Graph Description: 🔎 Search Terms resolution order dependent circular heritage, circular base type, circular mixin 🕗 Version & Regression Information This changed in #39675 However, it appears this PR was the first t...
X Description: 🔎 Search Terms resolution order dependent circular heritage, circular base type, circular mixin 🕗 Version & Regression Information This changed in #39675 However, it appears this PR was the fir...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/61711
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Resolution order dependent circular heritage","articleBody":"### 🔎 Search Terms\n\nresolution order dependent circular heritage, circular base type, circular mixin\n\n### 🕗 Version & Regression Information\n\n- This changed in #39675\n\nHowever, it appears this PR was the first time that circular heritage was (consistently) reported. Therefore this issue has essentially always existed.\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?#code/PTAEDEEsA8FMBNSQGagJ4HsCuoDGGBbA2AOwBdQyALSAZ1ABtITZRsKMAnUWgd0jK4qlDKAAGAQVxkuABQAqAJQBMsMQDoAUPFi4GAQ06t8JWhWgAuUAElTZfSVyx5aAA6wAPGTewMqKTKcCiqwAHwA3JpRIKAAqrQIIjxUGLyUVPocJAxooPqgOu4kOo65GCTi8mJI9CxOtLSGuchc6caQnLhYBpwCaFoxEvTMADRtoMjM+gygRrQYDABuiYvTWKzwGLC1GBQEmWSwnFre7qAAIrBF8LQA8iQe8qGgALx5JGiR2ro9xgYNoACrQA3ppQKBXJwMK4rJdrncHgFIMsAKLIZC6MgAbQARJDoTiALoRTQAXyiOj0hlYJH0xForn0ThshwIoFB4JiUDgiBQ6GwPH4gmE1DoSQcSHIR2QTNgWnBp1Y1gIrgYsGI5EykHKrxsdgcThc7g85wwXQ1ZAAwv9aJbypMAOa46ysokk8nfKlGPA2lnq9lg0CWC5XUg3e4eJGo9GY3H41xuyIerkwRJ8zA4IwEDDLcZiADKWAARka1KAHaQjpBcBDDHTYIdjpoqQCgUElKoPIWSz5dQ40M9YNBDsV6G32cmwNy06gM7N1TnWNRWAXi6XqhWWL0a4zOPXG1oW-QXergp3u6W+x9B8Ow8fWROosxGzLmabzaQrTa7SRHQHOVOqa8rOApCA4FbiIqfiAtIcgdmWMiQT40Ftmenj9qEYiBm2VhQf4sHtiEXwARAQFICBOBgSQEFiHhfoEGh1SIbRyGoCeDHwR4GFYeC7G4ax9FoUmFI-NSPr6K20jIrAaIYtIoBDiONygNakCfu+WAWgAsjAzAABQAEISbAUYyTG0gAJT-hCUIwqAJCaUWRzCZ6vwTFgjhkNqFSqepZqaZ+OnQMwHiBimPLkfyOAMBgGAJBUy54OUZh7s+bCoGIRkJNaEm0BogZZbAOUAopd72bAaR6eo1WGA6tBWP2WKElZLzPBgRYAFaYiMmihIZxlWIVxW0BZg3GcNXyUm5R6gIVpmyZi1kmClWAEVVNWcHVsKhqOEbseoyqquqn5auUoQWUmQA\n\n### 💻 Code\n\n```ts\n// Fixed if you comment this line out or switch to `ActorPTR2e`.\ndeclare const x: InstanceType\u003ctypeof ActorPTR2e>;\n\n\n// Used to show that only a dependency on `T` is necessary for the circularity.\n// As in, the final resolved value does not matter.\ntype DependsOn\u003cT> = any;\n\ndeclare class Actor {\n prop: DependsOn\u003cActiveEffect[\"prop\"]>;\n}\n\ndeclare namespace Item {\n // Fixed if you switch this to an interface.\n type Implementation = InstanceType\u003cDocumentClassConfig[\"Item\"]>;\n}\n\ndeclare class Item {\n x: DependsOn\u003cActiveEffect[\"prop\"]>;\n}\n\n// Fixed if you remove the `SubType` generic parameter.\nclass ActorPTR2e\u003cSubType = any> extends Actor {}\n\n// Fixed if you remove the `SubType` generic parameter.\nclass ItemPTR2e\u003cSubType = any> extends Item {}\n\ninterface DocumentClassConfig {\n // Fixed if you change `typeof ActorPTR2e` to `typeof ActorPTR2e\u003cany>`\n Actor: typeof ActorPTR2e;\n\n // Fixed if you change `typeof ItemPTR2e` to `typeof ItemPTR2e\u003cany>`\n Item: typeof ItemPTR2e;\n}\n\ndeclare class ActiveEffect extends ClientDocumentMixin(BaseActiveEffect) {\n prop: number;\n}\n\ndeclare function ClientDocumentMixin\u003c\n // Fixed if you loosen the constraint of `BaseClass`.\n BaseClass extends new (...args: any[]) => object,\n>(Base: BaseClass): BaseClass;\n\ndeclare class BaseActiveEffect {\n constructor(...args: DependsOn\u003cItem.Implementation>);\n}\n```\n\n\n### 🙁 Actual behavior\n\nNumerous errors, namely:\n```\nType alias 'Implementation' circularly references itself.\nType 'ActiveEffect' recursively references itself as a base type.\n'ActiveEffect' is referenced directly or indirectly in its own base expression.\n'args' is referenced directly or indirectly in its own type annotation.\n```\n\n### 🙂 Expected behavior\n\nNo error, as seen when you comment out the line `declare const x: InstanceType\u003ctypeof ActorPTR2e>;`. The error going away indicates that this circularity is resolution order dependent.\n\nI understand how odd the code is out of context but I did actually run into this in a real codebase.\n\n### Additional information about the issue\n\n_No response_","author":{"url":"https://github.com/LukeAbby","@type":"Person","name":"LukeAbby"},"datePublished":"2025-05-16T09:25:50Z","url":"https://github.com/microsoft/TypeScript/issues/61711"}
| 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:3211438f-0b91-e81e-d446-d195ffafdc93 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D7FE:26ECEB:E3EDBB:125025A:6B00F6FA |
| html-safe-nonce | 47308f3ae4621dba82b18735aae654067596e14eced76098df480179c1b86d73 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0ZFOjI2RUNFQjpFM0VEQkI6MTI1MDI1QTo2QjAwRjZGQSIsInZpc2l0b3JfaWQiOiI2NDU2OTY3NzAzMzI3NDcxMzU0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0696ea8e514ce6ec01b7053bd66847e7ee4729ed6a457abd6b2528800315db41 |
| hovercard-subject-tag | issue:3068468706 |
| 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/61711/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bb1db558da125747ead10037219c58b36560fe353c7812b3b1ff5354826a99cc/microsoft/TypeScript/issues/61711 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bb1db558da125747ead10037219c58b36560fe353c7812b3b1ff5354826a99cc/microsoft/TypeScript/issues/61711 |
| og:image:alt | 🔎 Search Terms resolution order dependent circular heritage, circular base type, circular mixin 🕗 Version & Regression Information This changed in #39675 However, it appears this PR was the first t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LukeAbby |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width