You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeBodyChecksHeritage<O>=OextendsPlaceableObject ? O : never;typeConstraintChecksHeritage<OextendsPlaceableObject>=any;// Name must extend something i.e. `GetConfigured<Name> = ...` compiles but this doesn't.typeGetConfigured<Nameextendsany>=ConstraintChecksHeritage<BodyChecksHeritage<// Changing this to `Name extends "AmbientLight" ? AmbientLight : Token` fixes the compilation.InstanceType<Nameextends"AmbientLight" ? typeofAmbientLight : typeofToken>>>;// 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.declareclassPlaceableObject<Unused=any>{// To fail to compile must contain an optional property that refers to `this`.a?: this;// This property exists to differentiate from the type `{}` but it isn't actually necessary to cause the compilation failure.
#notEmpty: true;}// To show this compilation failure the class could literally be just `class AmbientLight {}`. It has to exist though.declareclassAmbientLightextendsPlaceableObject{
#notEmpty: true;}declareclassTokenextendsPlaceableObject{// Must refer to another property. `this` alone isn't enough.b: this["c"];// Only exists to be referred to. Technically you could remove this and the "excessively deep" error doesn't go away.// However that causes another compilation error.c: number;}
π Actual behavior
Gets the error "Type instantiation is excessively deep and possibly infinite."
π Expected behavior
No error.
Additional information about the issue
I'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?
I'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:
π Search Terms
Type Instantiation is Excessively Deep, #56004
π Version & Regression Information
This changed in commit 38ef79e
β― Playground Link
https://www.typescriptlang.org/play/?#code/C4TwDgpgBAQg9gExAYQBYQMYGsDOAJCAJwEtgBDAcwgB4B5APigF4paoIAPYCAOwRygAFADZkMEMgCNhEWpIBWmYFAD8rKAC4oPCADciAbgBQoSFGRweOYITLEewNJlwES5KnXZde-IaPFSMnKKGMCMLGQ8IMZGAPSxUAByZAC20CkArtZe3HxQOHBpwKj2FFDEAHQQFVAABgDiEI6WAGbEFBmEEAjUyWnhUBVDtVAYhWDEMgKSGcrFxAIIcBA4PADkwBUm4NCNzTxtHV09fdCcub6RIAMWVjZ2Dk7Y+ESklDRGULCIKOjPrm8PJ8vlB4uZUJEKKUoPMBMA4HVTjkfAIAEQAQRSkmIvGAABl2qhgKjVFBMdjcQSKETNFAACpwLC8EZtDgrGHoUbjSZkYDESxbEFQACSd0i4jpO2owKFSPOKKgGKxOIcVKJJLUpggcBaZOVlMJyi0Wp19MZvBlUHowOt9BiYPRMJ2UDAZFsRSI5QEXQAjhliMcoC04IQOQsuSkJqI+ZYg3ZhJ1qiLlBhIlBJNAst0oJEEPk+cJhHHJjCEWNI5NoDNlMRdaQ1t6ICk4Po87iAxBhCByinuVMtghMKIuqNRDgBCIxBJpLIFEpqABVHhZvMRKKMADewLBDOLRfhEaj6SyvYcDxzPCgcDAMZ4ZCLYEI16IoA5vKgXRaRDhCNqsNqgo5ioxolDgMRfDuoEuk+kCEK+nALMAP5QAgtZfl0DjELy0AtE+KQctAWp1BuAC+IzVj2XrrMoYjABk95dtomArDgbrdgeqZZgRh48ree6JoBADEPBwMAACikagMahAZBAxgkUYcQJLuOCoHAADuYYCOWUa8vyl4tPGibcRgY7aXAGTCHmwikEQDHdhmUDyCedSmWQ456hSqqGlApEAcmUAQshCHZMUFnUgOQ5utAbkeeSKr4j58p8BO-jTkEc6hL5wLCaJEk3iA0myfJimDm5I6xQIDJMpeyW+JOAQzsESjZRBCQALIuZ+noHpEonoKGj7PnBIA1H+oEjPeljQAs1HsCJGQRcCkggQsADaqIYKiAC64GggktA8IxIVIaW6bQN1hCBvCNR0pgqA8MQqaFt2IAWVyll5l0zb6FpF55sU0Copw4jjsQ+iMYOEBgCSRBPqGSwrHNFAImQ6lkKN24JHgGl6D1EIpmQWYCH1gOhjpvH6ewV0hoBGBaMuWKGEYJFAA
π» Code
π Actual behavior
Gets the error "Type instantiation is excessively deep and possibly infinite."
π Expected behavior
No error.
Additional information about the issue
I'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?
I'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:
Name extends any
is required because Improve constraints of conditional types applied to constrained type variablesΒ #56004 only operates in cases where the type parameter is constrained.BodyChecksHeritage
andConstraintChecksHeritage
are both required to increase the depth.But that leaves some things I can't personally explain such as:
a?: this
causing issues buta: this | undefined
or others don't necessarily?PlaceableObject
have to be generic?I've noted more oddities inline with the code.
The text was updated successfully, but these errors were encountered: