OverviewHistoryStatsSecurity
npx skills add ...
Documentation
SKILL.md
npx skills add luumenlabs/luau-skills --skill luau-types
Use for Luau type-system work focused on strictness modes, annotations, inference-aware API design, generics, refinements, advanced type patterns, and Roblox-aware type usage at the type level.
npx skills add luumenlabs/luau-skills --skill luau-types
Use this skill when the task is primarily about Luau's type system:
--!strict, --!nonstrict, and other file type-checking modes.any.IsA knowledge only to improve static typing.Do not use this skill when the task is mainly about:
--!strict guidance for new or actively maintained code unless the task explicitly targets transitional or legacy code.any.luau-core.luau-performance.roblox/* skill instead.--!strict for strong inference and early error detection.--!nonstrict for transitional code where unresolved values would otherwise become noisy.--!nocheck only when the task explicitly requires disabled analysis.self, or prevent unwanted widening to any.{T} for arrays,T? for T | nil,:: as a precision tool, not a bypass. Use them to narrow overly generic inference, not to hide unrelated-type errors.any when a type parameter can express intent.setmetatable, and annotate self explicitly when methods need the shared class type.Instance, Part, Enum.Material, datatypes, and IsA-driven narrowing.references/type-system-overview.md for file modes, structural typing, annotations, casts, and module-boundary guidance.references/basic-types-and-table-typing.md for builtin types, special types like any and unknown, function signatures, table states, and indexers.references/generics.md for generic aliases, generic functions, defaults on aliases, and inference-preserving container patterns.references/unions-and-intersections.md for result shapes, tagged unions, discriminants, and safe intersection usage.references/refinements.md for truthy checks, type(...) guards, equality narrowing, compound conditions, and assert-based narrowing.references/object-oriented-typing.md for metatable-backed class typing, self annotations, constructor return types, and exported instance aliases.references/type-functions.md for analysis-time type computation, available libraries, and when advanced type-level transforms are justified.references/roblox-types-in-luau.md for Roblox class, datatype, enum, constructor, service, and IsA typing behavior.any is avoided unless intentionally opting out.self typing is explicit where Luau cannot safely infer the shared class type.--!nonstrict and unintentionally turning it into any.any or an overly broad union.: to automatically share a precise self type across the whole class.:: to force unrelated conversions instead of fixing the underlying type design.string & number.self--!strict
local function first<T>(items: {T}): T?
return items[1]
end
local a = first({1, 2, 3}) -- number?
local b = first({"x", "y"}) -- string?--!strict
type Loading = { kind: "loading" }
type Ready<T> = { kind: "ready", value: T }
type Failed = { kind: "failed", message: string }
type State<T> = Loading | Ready<T> | Failed
local function readValue(state: State<number>): number?
if state.kind == "ready" then
return state.value
end
return nil
end--!strict
local Counter = {}
Counter.__index = Counter
type CounterData = {
value: number,
}
export type Counter = typeof(setmetatable({} :: CounterData, Counter))
function Counter.new(initialValue: number): Counter
return setmetatable({
value = initialValue,
}, Counter)
end
function Counter.increment(self: Counter, amount: number): number
self.value += amount
return self.value
end
return Counter