一键导入
roblox-luau-types
Use for Luau annotations, generics, unions, narrowing, strictness, sealed tables, module type exports, or typed metatables.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use for Luau annotations, generics, unions, narrowing, strictness, sealed tables, module type exports, or typed metatables.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Use when implementing Roblox character animations, particles, beams, trails, tweens, camera shake, or other visual effects.
Use when building Roblox menus, HUDs, shops, notifications, dialogs, or responsive cross-platform UI.
Use when handling Roblox keyboard, mouse, gamepad, touch, motion input, or cross-platform action binding.
Use when validating RemoteEvent or RemoteFunction arguments, adding rate limits, designing server-authoritative systems, or preventing exploits.
Use when creating Roblox NPCs or enemies with pathfinding, state machines, line-of-sight or FOV detection, spawns, or AI update loops.
Use when building Roblox vehicles, ragdolls, projectiles, elevators, constraints, forces, or other physics-driven gameplay.
基于 SOC 职业分类
| name | roblox-luau-types |
| description | Use for Luau annotations, generics, unions, narrowing, strictness, sealed tables, module type exports, or typed metatables. |
| last_reviewed | "2026-05-27T00:00:00.000Z" |
| sources | ["https://luau-lang.org/typecheck"] |
Load for Luau type system work: annotations, generics, union types, type narrowing, sealed/unsealed tables, strictness modes (--!strict vs --!nonstrict), module type exports, and metatable-backed object typing. For syntax questions, use roblox-luau-core. For OOP/async/modules, use roblox-luau-patterns.
Strictness: --!strict (new code), --!nonstrict (transitional), --!nocheck (legacy only). The New Type Solver (GA Nov 2025) is faster/more accurate.
Inference philosophy: Infer first, annotate boundaries (params, returns, exports). Don't annotate every local — noise hides signal.
Sealed vs unsealed tables:
local t = {} -- unsealed: can add fields
t.x = 1 -- OK
local t: {x: number} = {x=1} -- sealed: no new fields
t.y = 2 -- ERROR
Build tables fully before annotating. Passing/returning seals them.
Unions & tagged unions:
local id: string | number = "abc"
type State<T> = {kind:"loading"} | {kind:"ready", value:T} | {kind:"fail", msg:string}
-- Discriminate: if state.kind == "ready" then state.value is narrowed
Narrowing:
if typeof(x) == "string" then ... end -- primitive narrowing
if inst:IsA("BasePart") then ... end -- Instance narrowing
assert(val, "missing") -- non-nil narrowing
Generics: Use when input→output type matters. function first<T>(list: {T}): T?. Generic aliases: type Result<T> = {success: boolean, value: T?}. Never replace with any.
Type exports: export type Foo = {...} at module boundary. Consumers use require + Types.Foo.
Object typing: export type Counter = typeof(setmetatable({} :: CounterData, Counter)) for precise self.
Casts (::): Precision tool to narrow overly generic inference — never to hide errors.
Key mistakes: Unsealed any propagation in nonstrict, sealing tables too early, unions without discriminants, annotating every local.
Full reference: see
references/full.md