Skip to content

luau ​

luau
local luau = require("@lute/luau")

WARNING

These APIs are still open to future evolution. In new major versions, they may change in backwards incompatible ways.

Summary ​

EntryDescription
BytecodeCompiled Luau bytecode produced by luau.compile.
TypeA resolved Luau type, as returned by typeofModule.
TypePackA resolved Luau type pack, as returned by typeofModule.
compileCompiles Luau source to bytecode.
loadLoads bytecode into a callable function. chunkname names the chunk for error messages. An optional env table can override the global environment.
resolveModuleResolves the require path path relative to fromchunkname, returning the absolute path.
typeofModuleReturns the type pack representing the return types of the module at modulepath, or nil if unavailable.

Types ​

Bytecode ​

Compiled Luau bytecode produced by luau.compile.

luau
type Bytecode = { bytecode: string }

Type ​

A resolved Luau type, as returned by typeofModule.

luau
type Type = {
	tag: "nil"
		| "unknown"
		| "never"
		| "any"
		| "boolean"
		| "number"
		| "string"
		| "buffer"
		| "thread"
		| "singleton"
		| "negation"
		| "union"
		| "intersection"
		| "table"
		| "function"
		| "extern"
		| "generic",

	-- for singleton type
	value: string | boolean | nil,

	-- for negation type
	inner: Type,

	-- for union and intersection types
	components: { Type },

	-- for table type
	properties: { [string]: { read: Type?, write: Type? } },
	indexer: { index: Type }?, -- TODO: add readresult and writeresult
	-- TODO: readindexer: { index: type, result: type } }?,

TypePack ​

A resolved Luau type pack, as returned by typeofModule.

luau
type TypePack = {
	tag: "typepack" | "variadic" | "generic",
	head: { Type }?,
	tail: TypePack?,

	-- for variadic type packs
	type: Type,
	hidden: boolean,

	-- for generic type packs
	name: string,
	ispack: boolean,
}

Functions and Properties ​

luau.compile ​

Compiles Luau source to bytecode.

luau
(source: string) -> Bytecode

luau.load ​

Loads bytecode into a callable function. chunkname names the chunk for error messages. An optional env table can override the global environment.

luau
(bytecode: Bytecode, chunkname: string, env: { [any]: any }?) -> (...any) -> ...any

luau.resolveModule ​

Resolves the require path path relative to fromchunkname, returning the absolute path.

luau
(path: string, fromchunkname: string) -> string

luau.typeofModule ​

Returns the type pack representing the return types of the module at modulepath, or nil if unavailable.

luau
(modulepath: string) -> TypePack?