Global type exporting

Pretty simple question. I was wondering if there is a way to make some types that I create global, or even if I could stick them in a module called Types or something. It would just make my code cleaner.

An example of the way I am currently making these types -

export type MainHand = {
	Animations : {[string] : number},
	Range : number,
	Angle : number,
}

export type OffHand = {
	Animations : {[string] : number},
	CanParry : boolean,
}

I would have to create these types in any script in which I wish to reference them, so I just want to know if there’s a way to store them somwhere, preferably globally.

1 Like

Nevermind, found out you can put it in modules!

Hi there!
Can you shrae your solution? I have just ran into the same issue and using Modules doens’t seem to work for me.

Sure. What I did was simply make a module called “Types” in Replicated Storage and it contained something that looked something like this:

local types = {}

export type Test = {
   testNum : number,
}

return types

Now, after doing this, to use the type in another script you would do something like so (in a far less crude way, of course):

local types = require(game.ReplicatedStorage.Types)

local testTable : types.Test = {
   testNum = 3
}

Hope this helps, sorry for the late response. I don’t frequent the forums very often.

2 Likes