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
| Entry | Description |
|---|---|
| Bytecode | Compiled Luau bytecode produced by luau.compile. |
| Type | A resolved Luau type, as returned by typeofModule. |
| TypePack | A resolved Luau type pack, as returned by typeofModule. |
| compile | Compiles Luau source to bytecode. |
| load | Loads bytecode into a callable function. chunkname names the chunk for error messages. An optional env table can override the global environment. |
| resolveModule | Resolves the require path path relative to fromchunkname, returning the absolute path. |
| typeofModule | Returns 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) -> Bytecodeluau.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) -> ...anyluau.resolveModule
Resolves the require path path relative to fromchunkname, returning the absolute path.
luau
(path: string, fromchunkname: string) -> stringluau.typeofModule
Returns the type pack representing the return types of the module at modulepath, or nil if unavailable.
luau
(modulepath: string) -> TypePack?