← Luau typing quick reference

Exported module types

Luau 0.731 · --!strict
export type Name = ...

A local type stays inside its module. export type lets consumers refer to it through the name bound by require.

When to use it

Read this page when you need to apply Exported module types, verify its exact contract, and adapt the example without bypassing validation or host boundaries.

Focused example

-- app/cards.luau
--!strict

export type Card = {
    id: string,
    color: "red" | "green",
}

local Cards = {}

function Cards.create(id: string, color: "red" | "green"): Card
    return { id = id, color = color }
end

return table.freeze(Cards)

-- app/main.luau
--!strict

local Cards = require("app/cards")
local card: Cards.Card = Cards.create("card-1", "green")

assert(card.id == "card-1" and card.color == "green")

Complete inventory

View all pages in Luau typing quick reference
← Previous: Function typesNext: typeof →