Why do you need to iterate through types? The types are used only to define what kind of variable you are creating/expecting to get. They don’t really store a purpose outside of that
I’m guessing the answer is just no to my original question, at least that’s what I’m getting so far. The other two “answers” were pretty useless to me. Thanks anyway lol.
Because I have a use case where it makes sense? I can think of many reasons for why I’d want to be able to get all of the different types defined in a module, especially if I wanted to take say, hundreds of module scripts, and pull all of the types in all of those module scripts into a single table for easy referencing.
Short answer, no. Long answer, not without doing it manually. Luau’s type system is so barebones that we can’t even import all types from a module without reserving the first 30 lines to “export type name = module.name”, kinda defeating the purpose of external type definitions in decreasing code bloat.
The one above who said “return a table” probably meant you should return an array listing all types your module has. Maybe give it a similar structure to this until we finally get a functional system:
export type name1 = ...
export type name2 = ...
export type name3 = ...
return {
_types = {"name1", "name2", "name3"}
}
I know you marked this as solution but its important to note that they will probably invent a proper way to do this so dont use this for long. unless they dont, haha ha.