Roblox Luau Types

TabooHarmony/roblox-brain/skills/core/roblox-luau-types

by TabooHarmony38826be57ee37bcf023e9c2b85681bea3909281cNo licenseListed Oct 9, 2026Updated Oct 9, 2026

Use for Luau annotations, generics, unions, narrowing, strictness, sealed tables, module type exports, typed metatables, or new-solver features.

AI-generated overview

Reference guidance for Roblox Luau type annotations, generics, unions, narrowing, strictness modes and new-solver features.

What it does
This skill supplies a condensed reference on the Luau type system for Roblox development. It covers strictness directives, the new type solver gate, inference philosophy, sealed versus unsealed tables, unions and tagged unions, narrowing, generics, module type exports, typed metatables, casts, trust boundaries and common mistakes. It points to a fuller reference document for worked examples.
When to use it
Use it when writing or reviewing Luau code that involves type annotations, generics, unions, narrowing, strictness settings, sealed tables, module type exports, typed metatables or new-solver features such as keyof and type functions. It is not intended for general Luau syntax or OOP and async patterns, which are handled by other skills.
Requirements
No scripts or runtime dependencies; it is an instructions-only skill. It references a bundled reference document (references/full.md) and cites external documentation sources, so reading the full reference requires access to that file.

Luau Type System

When to Load

Load for Luau types: annotations, generics, unions, narrowing, sealed/unsealed tables, strictness (--!strict vs --!nonstrict), module type exports, metatable typing, and new-solver features (keyof, setmetatable<T, M>, type functions, read). For syntax, roblox-luau-core; for OOP/async, 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(v) == "string" narrows primitives, instance:IsA("BasePart") narrows Instances, assert(v, "msg") removes nil. Discriminants narrow tagged unions; full reference has worked examples.

Generics: Use when input→output type matters: function first<T>(list: {T}): T?, or type Result<T> = {success: boolean, value: T?}. Never replace with any.

Type exports: export type Foo = {...} at module boundaries; consumers use Types.Foo.

Object typing: typeof(setmetatable({} :: CounterData, Counter)) types precise self; the new solver adds setmetatable<T, M> directly.

Casts (::): For narrowing overly generic inference, never for hiding errors.

Trust boundaries: Annotations contract with the compiler, not runtime data. Remotes, DataStores, HttpService, and attributes still need checks; inside a trusted boundary, let types carry the load.

Key mistakes: any propagation in nonstrict, sealing too early, unions without discriminants, annotating every local, deleting new-solver syntax without checking the solver setting.

Full reference: see references/full.md

Source and attribution

Source:TabooHarmony/roblox-braininskills/core/roblox-luau-typesat commit38826be

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal