Can we access special types in Luau? How can we get something close to this?

How can use the special types certain API’s use on the DevHub? Do we have to create them ourselves? Does Luau allow this?

I’m currently starting to use types, and have become curious about this. I’ve noticed on the DevHub we see that many arguments use their own type, i.e. HttpService:PostAsync() has HttpContentType as the type for the arguement. Lots of others use Variants, which upon clicking leads me to Tuple.

What type should we use? Do we need to create our own type for this? Why is this not part of Luau?

Thanks! :grin:

I don’t think I fully understand your question, but from what I can gather, I assume you’re asking if you can use types such as Tuple. AFAIK, you can’t.

However, you can create a Tuple-like return type:

function return_tuple() : ...any
    return 1, 2, 3, 4, 5

variant is equivalent to any

As for your other question as to why it’s not part of Luau, I’m not sure.

However, we can use other types such as HttpContentType through Enum.HttpContentType

1 Like