Do you have to index the module every time you use export type?

Hello!

Basically I was wondering if every time you use a custom type in a module if you have to index the type through the module every time?

Let’s say I have this script:

local types = require(script.Parent:WaitForChild('Types'))
local thing: types.CustomType -- I have to use types.CustomType

is there a way to just do

local types = require(script.Parent:WaitForChild('Types'))
local thing: CustomType -- can I do it like this somehow?

without having to define the types inside of the script that would be requiring the types module?

Also this is what’s inside the Types module:

export type CustomType = {
	Title: string?;
	Body: string;
}

return nil

No, there isn’t another way, you’d have to stick to this for now.

1 Like