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¶
Defines a named type alias.
@class¶
Describes a Lua table type; this does not create a native Tua class.
@field¶
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¶
Types a Lua function parameter. Native Tua annotations must agree with this contract.
@return¶
Describes function return values.
@type¶
Provides a type for a Lua declaration.
@overload¶
Adds a known call signature for signature help and call checking.
@vararg¶
Types variadic Lua function arguments.
@deprecated¶
Marks an API deprecated; uses report TL4056 and editor surfaces show the guidance.
@nodiscard¶
Reports TL4068 for a direct call statement that discards the resolved function result.
@generic¶
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¶
Metadata only. Does not select a runtime or change checking.
@enum¶
Metadata only. Does not create a checked enum type.
@meta¶
Identifies configured type_libraries declaration modules; does not execute or install a runtime library.
@module¶
Metadata only. Does not import a module or resolve a runtime dependency.
@diagnostic¶
Metadata only. Use Tua ignore directives to suppress Tua diagnostics.
@cast¶
Metadata only. Does not narrow or cast the value in Tua.
@as¶
Metadata only. Does not change expression inference in Tua.