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
The line with Trait21F(...) where we assign to ConcreteBase throws the "type instantiation is excessively deep" error. The error goes away if there is at most 20 mixins (e.g. the last one is Trait19F), so any number more than 20 seems to be the problem.
It's worth noting that if for every trait we had a static class e.g. class Trait0 extends Trait0F(BaseObj) and then intersected them all together, e.g. const ConcreteBase = typeof Trait21 & ... & typeof Trait0 & typeof BaseObj that everything works (TS playground), which feels like it should be functionally equivalent.
Expressing this the manual way, by having the equivalent trait classes extend each other statically (class Trait1 extends Trait0 etc...), also works: TS Playground
π Expected behavior
I would expect this to not error. This recursion isn't infinite and doesn't seem like it would exceed the depth limit of 100 currently hard-coded into the compiler, and in general the 2 alternatives which work should be equivalent.
I would expect this to not error. This recursion isn't infinite
The error message says "excessively deep" and, yeah, a 20-deep function call qualifies as "too deep" for the purposes of not crashing/hanging in other codebases. You'll need to use a workaround.
π Search Terms
Mixin mixins 20 21 type instantiation is excessively deep and possibly infinite
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?#code/IYIwzgLgTsDGEAJYBthjAgQmgpgeRACsEBvAKAUqQHsA7SKAV3mqgAoA6L4KAczABcCYLQCeAbQC6ASlIBfMgrIUEAM0a14ASzoIAKjC0QADADEAPHuxgcCHAA8IOWgBMMEUQAcc1VVlwEhAB8bNY4Qla40uRUwuDQcIgoaBgGwEbGdo7Obv428iqUUDgQjFC0+oYmKkoq6poQOhVpRgCMFpH5Dk6u7l4+fmGBIWERYdGFcQyJSKjolekQrVk9uWEFscWl5QttNcp1Gtq6LRAATB3r3Tl93r55+EQjuGNRMVSg0-CzKbvnKzcHhsqFsys0qmd9spKPVjuDFgBmS64AG9BAeO6DAJPUIvfTjd6UT4Jb7JeanBGotYokgKTYlMF-BFQw4NJp-AAsyK62TRGIGD2GuJsrxsE1ixJgpLmqSqHKpGHWtMmoJ2pw5LJhR0aJyqAFZubZrnz+vchjjRvi3pNJTMybLFnqFUDlfTtvCjHrNWptezTgA2Q3O-lm7HBYXhK1iwlTElJGV-f3OpV0kEMtVVf3e2E6j0QADsQeNuRDWJsQstnRw4o+8Sl8d+p3zyZpqaK6bz+ezvt1iwAHEXeSXTWXHuHKwSbXW7QnTn2W-lXWn3X8+922b2jABOQerW4C83jvFVmtE6fSxtVLcL2xL9sr05b9dwv6tMyWK5D-eh8sW4+TiVzwbckqjfG9gXvRlTjfZ9c1fdoPxRYtv1HCt-2tQCvmAh02mWZCXTbBBVTzVpWlgv1QIuRCeT3dER0FP8RSjasY1tC8QMWVoznAu8iI7V9IUoWotQ3EikWoo0vzozEGKPJiT1YoCfg4tpKXwlMVX46DmSEg4RJfaCuQk4N6MPZ55IA2ssOUnClnldTW00h9QI1XToR9UTXwNYz8NLWTzMjBSp2s+0vJ4wjiK88jNyWQMfKkvyzIjUUWOCuMbNfJMHMXCKtNArM3NZAzQMLeLaMSsMApS09Y3rDLoObbLb1y5zOK7Qr9Lg6CBzKwEKt-OTAsss8QtnUD5yaiC+Nato1w6jzis4ndepNGSkonDCrPS0LoOvSbeMi3borzM53yrEy1sq5LmJqtjsL+U7wqcqCIWMY6HoQ87fNMq6NujNK6p2iE8KkjS3RexYzjItzYDoSAEAAYToWAthwdYAF4PtMNhTlO7Hdvx8bCba4m2kDHHQINCnOK5anVNJpYLjppZ2mZt8GZ3ZmB2ZwtmfJ04qfVBmkWZpnoIZswI0CaQZdluX5YV6QAG5lFCpHNFRhGAAstGQFxnXVlGSjR1sgA
π» Code
π Actual behavior
The line with
Trait21F(...)
where we assign toConcreteBase
throws the "type instantiation is excessively deep" error. The error goes away if there is at most 20 mixins (e.g. the last one isTrait19F
), so any number more than 20 seems to be the problem.It's worth noting that if for every trait we had a static class e.g.
class Trait0 extends Trait0F(BaseObj)
and then intersected them all together, e.g.const ConcreteBase = typeof Trait21 & ... & typeof Trait0 & typeof BaseObj
that everything works (TS playground), which feels like it should be functionally equivalent.Expressing this the manual way, by having the equivalent trait classes extend each other statically (
class Trait1 extends Trait0
etc...), also works: TS Playgroundπ Expected behavior
I would expect this to not error. This recursion isn't infinite and doesn't seem like it would exceed the depth limit of 100 currently hard-coded into the compiler, and in general the 2 alternatives which work should be equivalent.
Additional information about the issue
Related:
#34933
#54533
The text was updated successfully, but these errors were encountered: