Title: Type Instantiation is Excessively Deep Regression In #56004 · Issue #59667 · microsoft/TypeScript · GitHub
Open Graph Title: Type Instantiation is Excessively Deep Regression In #56004 · Issue #59667 · microsoft/TypeScript
X Title: Type Instantiation is Excessively Deep Regression In #56004 · Issue #59667 · microsoft/TypeScript
Description: 🔎 Search Terms Type Instantiation is Excessively Deep, #56004 🕗 Version & Regression Information This changed in commit 38ef79e ⏯ Playground Link https://www.typescriptlang.org/play/?#code/C4TwDgpgBAQg9gExAYQBYQMYGsDOAJCAJwEtgBDAcwgB4B5A...
Open Graph Description: 🔎 Search Terms Type Instantiation is Excessively Deep, #56004 🕗 Version & Regression Information This changed in commit 38ef79e ⏯ Playground Link https://www.typescriptlang.org/play/?#code/C4TwDgpg...
X Description: 🔎 Search Terms Type Instantiation is Excessively Deep, #56004 🕗 Version & Regression Information This changed in commit 38ef79e ⏯ Playground Link https://www.typescriptlang.org/play/?#code/C4Tw...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/59667
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type Instantiation is Excessively Deep Regression In #56004","articleBody":"### 🔎 Search Terms\n\nType Instantiation is Excessively Deep, #56004\n\n### 🕗 Version & Regression Information\n\nThis changed in commit 38ef79e0b02ad122b984a19f3494414e4e53c896\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?#code/C4TwDgpgBAQg9gExAYQBYQMYGsDOAJCAJwEtgBDAcwgB4B5APigF4paoIAPYCAOwRygAFADZkMEMgCNhEWpIBWmYFAD8rKAC4oPCADciAbgBQoSFGRweOYITLEewNJlwES5KnXZde-IaPFSMnKKGMCMLGQ8IMZGAPSxUAByZAC20CkArtZe3HxQOHBpwKj2FFDEAHQQFVAABgDiEI6WAGbEFBmEEAjUyWnhUBVDtVAYhWDEMgKSGcrFxAIIcBA4PADkwBUm4NCNzTxtHV09fdCcub6RIAMWVjZ2Dk7Y+ESklDRGULCIKOjPrm8PJ8vlB4uZUJEKKUoPMBMA4HVTjkfAIAEQAQRSkmIvGAABl2qhgKjVFBMdjcQSKETNFAACpwLC8EZtDgrGHoUbjSZkYDESxbEFQACSd0i4jpO2owKFSPOKKgGKxOIcVKJJLUpggcBaZOVlMJyi0Wp19MZvBlUHowOt9BiYPRMJ2UDAZFsRSI5QEXQAjhliMcoC04IQOQsuSkJqI+ZYg3ZhJ1qiLlBhIlBJNAst0oJEEPk+cJhHHJjCEWNI5NoDNlMRdaQ1t6ICk4Po87iAxBhCByinuVMtghMKIuqNRDgBCIxBJpLIFEpqABVHhZvMRKKMADewLBDOLRfhEaj6SyvYcDxzPCgcDAMZ4ZCLYEI16IoA5vKgXRaRDhCNqsNqgo5ioxolDgMRfDuoEuk+kCEK+nALMAP5QAgtZfl0DjELy0AtE+KQctAWp1BuAC+IzVj2XrrMoYjABk95dtomArDgbrdgeqZZgRh48ree6JoBADEPBwMAACikagMahAZBAxgkUYcQJLuOCoHAADuYYCOWUa8vyl4tPGibcRgY7aXAGTCHmwikEQDHdhmUDyCedSmWQ456hSqqGlApEAcmUAQshCHZMUFnUgOQ5utAbkeeSKr4j58p8BO-jTkEc6hL5wLCaJEk3iA0myfJimDm5I6xQIDJMpeyW+JOAQzsESjZRBCQALIuZ+noHpEonoKGj7PnBIA1H+oEjPeljQAs1HsCJGQRcCkggQsADaqIYKiAC64GggktA8IxIVIaW6bQN1hCBvCNR0pgqA8MQqaFt2IAWVyll5l0zb6FpF55sU0Copw4jjsQ+iMYOEBgCSRBPqGSwrHNFAImQ6lkKN24JHgGl6D1EIpmQWYCH1gOhjpvH6ewV0hoBGBaMuWKGEYJFAA\n\n### 💻 Code\n\n```ts\r\ntype BodyChecksHeritage\u003cO> = O extends PlaceableObject ? O : never;\r\ntype ConstraintChecksHeritage\u003cO extends PlaceableObject> = any;\r\n\r\n// Name must extend something i.e. `GetConfigured\u003cName> = ...` compiles but this doesn't.\r\ntype GetConfigured\u003cName extends any> = ConstraintChecksHeritage\u003c\r\n BodyChecksHeritage\u003c\r\n // Changing this to `Name extends \"AmbientLight\" ? AmbientLight : Token` fixes the compilation.\r\n InstanceType\u003c\r\n Name extends \"AmbientLight\" ? typeof AmbientLight : typeof Token\r\n >\r\n >\r\n>;\r\n\r\n// A type parameter is required for this compilation failure. It can be used and still fail to compile but if it's removed entirely it compiles.\r\ndeclare class PlaceableObject\u003cUnused = any> {\r\n // To fail to compile must contain an optional property that refers to `this`.\r\n a?: this;\r\n\r\n // This property exists to differentiate from the type `{}` but it isn't actually necessary to cause the compilation failure.\r\n #notEmpty: true;\r\n}\r\n\r\n// To show this compilation failure the class could literally be just `class AmbientLight {}`. It has to exist though.\r\ndeclare class AmbientLight extends PlaceableObject {\r\n #notEmpty: true;\r\n}\r\n\r\ndeclare class Token extends PlaceableObject {\r\n // Must refer to another property. `this` alone isn't enough.\r\n b: this[\"c\"];\r\n\r\n // Only exists to be referred to. Technically you could remove this and the \"excessively deep\" error doesn't go away.\r\n // However that causes another compilation error.\r\n c: number;\r\n}\r\n```\r\n\n\n### 🙁 Actual behavior\n\nGets the error \"Type instantiation is excessively deep and possibly infinite.\"\n\n### 🙂 Expected behavior\n\nNo error.\n\n### Additional information about the issue\n\nI've seen somewhat similar issues reported about this PR but none of them seemed to match my issue. However some were closed without reproduction and maybe I'm having the same problem as [type-fest is?](https://github.com/microsoft/TypeScript/pull/56004#issuecomment-1914382123)\r\n\r\nI've reduced the code down from a large project into this which is why it seems utterly contrived. A few of the odd requirements seem to be explainable:\r\n- `Name extends any` is required because #56004 only operates in cases where the type parameter is constrained.\r\n- `BodyChecksHeritage` and `ConstraintChecksHeritage` are both required to increase the depth.\r\n\r\nBut that leaves some things I can't personally explain such as:\r\n- Why is `a?: this` causing issues but `a: this | undefined` or others don't necessarily?\r\n- Why does `PlaceableObject` have to be generic?\r\n- etc.\r\n\r\nI've noted more oddities inline with the code.","author":{"url":"https://github.com/LukeAbby","@type":"Person","name":"LukeAbby"},"datePublished":"2024-08-17T11:49:08Z","url":"https://github.com/microsoft/TypeScript/issues/59667"}
| 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:0ab34445-e66b-dad0-e06f-9cf2716257c1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A920:F8826:E27DB8:127E417:6B04E849 |
| html-safe-nonce | fceb821d35ff61dd87f593ef070a15c81977bdc58a07d7b8caba2ad2f5aa3e04 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTIwOkY4ODI2OkUyN0RCODoxMjdFNDE3OjZCMDRFODQ5IiwidmlzaXRvcl9pZCI6IjQ0NDY3ODc0ODExMDY3MDQ0NTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d4b37068795678ca7bf6ea838a18d494ad0fdab33816fb2b2d9abfcc5073aebf |
| hovercard-subject-tag | issue:2471492446 |
| 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/59667/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ef049bfe5d2a2cd76eb2202d9061f8324a89501843dee462ce4f4902a0fb8731/microsoft/TypeScript/issues/59667 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ef049bfe5d2a2cd76eb2202d9061f8324a89501843dee462ce4f4902a0fb8731/microsoft/TypeScript/issues/59667 |
| og:image:alt | 🔎 Search Terms Type Instantiation is Excessively Deep, #56004 🕗 Version & Regression Information This changed in commit 38ef79e ⏯ Playground Link https://www.typescriptlang.org/play/?#code/C4TwDgpg... |
| 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 | f3851aad500d8e8dce736722ddc6fa9596e17d9fce3c53581eba968664c0bc32 |
| 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 | e29c922455fd8137f27e1cfcdf6a1e8b920b1926 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width