Skip to content

RFC: Export Type Barrel#186

Open
StoryBakeryDev wants to merge 1 commit intoluau-lang:masterfrom
StoryBakery:syntax-type-export-barrel
Open

RFC: Export Type Barrel#186
StoryBakeryDev wants to merge 1 commit intoluau-lang:masterfrom
StoryBakery:syntax-type-export-barrel

Conversation

@StoryBakeryDev
Copy link
Copy Markdown

Rendered

This RFC proposes a type-only barrel form for forwarding exported types from one module through another:

-- Child.luau
export type A<T, U> = ...
export type B = ...
export type C = ...

-- Interface.luau
export type * from "@self/Child"

-- Consumer.luau
local Interace = require("./Interface")

local a: Interace.A<any, any>
local b: Interace.B
local c: Interace.C

@Crazyblox
Copy link
Copy Markdown

Crazyblox commented Apr 3, 2026

This might not be what you are looking for, but I wanted to explore syntax for this on the side of the requirer rather than the export.

-- All export types: Assign to requirer top level.
type require("path/to/module")

-- All export types: Assign to requirer top level with option to reassign type names, preventing clashing.
type SpecificType = string
type require("path/to/module") {RenamedSpecificType = SpecificType}

-- Single export type: Assign to requirer top level.
type require("path/to/module").SpecificType

-- Single export type: Assign to requirer top level with option to reassign, preventing clashing.
type SpecificType = string
type RenamedSpecificType = require("path/to/module").SpecificType

@TenebrisNoctua
Copy link
Copy Markdown

Couldn't this be achieved in a more simplistic manner as:

local module = require("path/to/module")
export type module -- All types from the module can now be exported in this simplistic syntax.

You could still do:

local module = require("path/to/module")
export type A = module.A

For better control. This would use the existing type resolving system with require(), and may be less expensive to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants