Skip to content

Annotation Guide

Use -- for implementation comments, --- for API prose, and ---@ for Lua-compatible annotations. In native Tua code, prefer types on declarations and signatures; annotation contracts must agree with native types.

Type ---@ to discover tags and hover a complete tag for its meaning. In VS Code, run Tua: Open Annotation Guide (Offline) from the Command Palette. Tag completion inserts the tag name without replacing your existing arguments.

Recognition does not imply full LuaLS semantics. The descriptions below state which tags affect checking and which are metadata only. Enable [diagnostics] doc_annotations = true in tua.toml to report malformed supported tags. Use -- tua-ignore-next-line CODE for Tua diagnostic suppression.

@alias

---@alias Name Type

Defines a named type alias.

@class

---@class Name

Describes a Lua table type; this does not create a native Tua class.

@field

---@field name Type

Adds a typed field to the preceding annotation class. Repeating a callable field declares overloads, with each complete parameter list checked separately. For example, ---@field after fun(seconds: number, callback: fun()) and ---@field after fun(label: string, seconds: number, callback: fun()) describe two valid call forms. Ordinary field declarations keep their existing meaning.

@param

---@param name Type

Types a Lua function parameter. Native Tua annotations must agree with this contract.

@return

---@return Type

Describes function return values.

@type

---@type Type

Provides a type for a Lua declaration.

@overload

---@overload fun(value: string): number

Adds a known call signature for signature help and call checking.

@vararg

---@vararg Type

Types variadic Lua function arguments.

@deprecated

---@deprecated Use replacement instead

Marks an API deprecated; uses report TL4056 and editor surfaces show the guidance.

@nodiscard

---@nodiscard

Reports TL4068 for a direct call statement that discards the resolved function result.

@generic

---@generic T

An unbounded ---@generic T on a documented function binds T in its ---@param, ---@vararg, and ---@return types. Calls infer each use independently. Generic bounds and generic methods are unsupported in LuaDoc; use native Tua syntax for bounded generics and generic classes. See Generic Type Aliases in the Typing In Tua guide and Generic Protocol Bounds in the Classes guide.

@version

---@version 5.1

Metadata only. Does not select a runtime or change checking.

@enum

---@enum Name

Metadata only. Does not create a checked enum type.

@meta

---@meta

Identifies configured type_libraries declaration modules; does not execute or install a runtime library.

@module

---@module "module.name"

Metadata only. Does not import a module or resolve a runtime dependency.

@diagnostic

---@diagnostic disable: undefined-global

Metadata only. Use Tua ignore directives to suppress Tua diagnostics.

@cast

---@cast value string

Metadata only. Does not narrow or cast the value in Tua.

@as

---@as string

Metadata only. Does not change expression inference in Tua.