Build in an Array type to typed Lua

As a Roblox developer it is currently annoying to manually define an Array type in every script I write in the Typed Lua beta.

Arrays are one of the most common programming constructs. It is annoying to have to write type Array<T> = {[number]: T} at the top of every script. Because of this, the array type should be built-in and not have to be manually defined.

If an Array type were built in, it would make the lives of developers easier by making them waste less time writing out a type definition that is extremely common.


I normally don’t ‘bump’ feature requests but as I’ve started using typed Lua more, it’s become more and more obvious that an Array type being built-in would be a serious time saver. I have a definition for Array at the top of almost every script at the moment.

Is there any chance that some more advanced built-in types (Array, Map, etc.) will be added @zeuxcg?

We are planning to introduce builtin syntax for array-like table types, {T}. No word on richer runtime types - this is considered for long-term evolution of the language, but there be dragons so we don’t know yet if we’re going to do it vs cleaning up some idiosyncrasies with tables where possible vs living with what we have.

1 Like

That’s good to hear – Array<T> would still be my preference though. {T} seems like it wouldn’t stand out compared to the existing table syntax.

For the most part, the syntax for tables has been fine. I’ve not ran into any issues with them or found circumstances where they’ve been excessively verbose. That isn’t to say they don’t exist (if you’ve noticed some, I believe you), just that they’re not obvious to me at least.

{string} seems pretty distinct? We also looked at both Typed Lua and Teal and both use the same syntax.

Suppose so, actually. I was imagining it in a setting like {[string]: {number}}, but even then it looks alright.

I withdraw the concern.