Share the same type across multiple scripts

How could I share the same type/s across multiple scripts? I thought that I could maybe put them into a table in a module script and return it, but that doesn’t work.

Example of what I’m trying to accomplish:

-- ModuleScript
local types = {}

type types.Food = {Name: string, Price: number}

return types

-- Script
local types = require(ModuleScript)

local foodTable: {types.Food} = {
  {Name = "Burger", Price = 100},
  {Name = "Pizza", Price = 150}
}

I don’t necessarily need the types in a table, I just want to use them in multiple places.

-- ModuleScript
export type Food = {Name: string, Price: number}

return nil

-- Script
local types = require(ModuleScript)

local foodTable: types.Food = {
  {Name = "Burger", Price = 100},
  {Name = "Pizza", Price = 150}
}
4 Likes