roblox-luau-types
Luau Type System
When to Load
Load for Luau annotations, inference, narrowing, strictness, exports, and solver features. Syntax: roblox-luau-core; lifecycle/scheduling: roblox-luau-patterns.
Quick Reference
Strictness: --!strict for maintained code, --!nonstrict while transitioning, --!nocheck only for legacy or generated code. Directives and project settings select the mode; never assume one global default.
New solver gate: keyof, rawkeyof, setmetatable<T, M>, type functions, and read members need the new type solver. On by default for nocheck/nonstrict projects; strict projects need Workspace.UseNewLuauTypeSolver = Enabled (Scripting). Errors here usually mean wrong solver, not wrong syntax.
Inference philosophy: Infer first; annotate boundaries (params, returns, exports). Don't annotate every local.
Sealed vs unsealed tables: An unannotated local table stays open to new fields until annotated, returned from a function, or its scope exits; annotation seals it. Build tables fully before annotating; passing a table to a typed function does not seal it.
Unions: local id: string | number is a union; prefer tagged unions (type State<T> = {kind:"loading"} | {kind:"ready", value:T}) and discriminate on kind to narrow.
Narrowing: typeof, IsA, assertions, and tagged discriminants refine types; examples in full.md.