Increase the threshold from which a script is considered "too complex" for the Luau-powered type checker

Over the past couple days, I have been rewriting the entirety of the game I develop. One of the changes to the codebase makes it use new Luau features, one of these being strict type checking.

I have repeatedly run into issues where my types are dubbed “too complex” to validate, which causes all analysis on the type and anything that uses that type to completely fail.

Unfortunately, splitting these types or simplifying them is not an option for my use case. When I make these types, they are a union between the module’s declaration and an instance created by that module.

local MyModule = {}
MyModule.__index = MyModule

type MyModule = typeof(MyModule) & {
    SomeInstanceProperty: number,
    -- ...
return MyModule

This allows autocomplete to browse all of its methods and properties together for an instance of my type. Unfortunately, the primary type that my game is centered around is extremely massive (the static module type has ~130 method declarations, and ~100 total instance member declarations, some nested more than others). Each of these methods has some signature associated with them, many returning some of the subtypes of this major type. To add to the pile, the companion to this module is a class extending it, so on top of that ~230 members, it adds its own ~200 members (about a third of them are overrides, the rest are not).

This limit has been problematic for my work, because I rely on autocomplete and intellisense to help me work with my code. When it is stopped from working, not only am I unable to work with that script as easily, but anything that uses that script has its autocomplete rendered completely useless.

Edit: An alternative would be to expose this limit in Studio’s preferences.


Thank you again for the report.

Right now, we don’t have plans to expose the limits as those can cause Studio to fail to open the place file if set up incorrectly (and with known code patterns that hit the limit ceiling easily).
We have people working to fix some popular code patterns from easily hitting the limit and we will most likely increase current limits to handle code bases with large type networks.


That makes sense. I was even hit by these place loading failures myself so I am all too familiar with that issue.

I’m looking forward to it. While I have been able to wrestle my script back under that limit on occasion, I have to do API changes somewhat frequently as I continue my work, and it often pushes it back over that limit. It’s become quite annoying.

If you or any other folks working on that part of studio would like, I can do private contact to supply the scripts I have that are collectively causing problems for me.

1 Like

We have increased the internal limit a bit.
We know that it can still be hit, so we are still working on fixing other analysis issues.

Hopefully it will alleviate most of the cases where you’ve experienced problems. If not, there are improvements planned in the next Studio update (edit: and in updates after that).