All Annotations
Quick reference for every annotation wowlua-ls supports. For detailed usage and examples, see the guide.
Type annotations
| Annotation | Description | Guide |
|---|---|---|
@param name type | Parameter type. name? for optional. | Basic Annotations |
@return type [name] | Return type. Multiple lines for multi-return. | Basic Annotations |
@return (A, B) | (C, D) | Tuple-union return with correlated narrowing. | Multi-Return |
@return ...T | Variadic return — fills remaining positions with T. | Multi-Return |
@type type | Variable type annotation. | Basic Annotations |
@as type | Inline expression type assertion (--[[@as T]]). | Basic Annotations |
@cast var [+|-]type | Change variable type: replace, add (+), remove (-). | Basic Annotations |
Class annotations
| Annotation | Description | Guide |
|---|---|---|
@class Name | Define a named class type. | Classes |
@class Name : Parent | Class with inheritance. | Classes |
@class Name<T> | Parameterized class. | Generics |
@class Name<T: Constraint> | Parameterized class with type constraint. | Generics |
@enum Name | Enum type — bidirectionally compatible with number. | Classes |
@field name type | Class field declaration. | Classes |
@field [K] V | Bracket-index field. | Generics |
@field private name type | Private field. | Classes |
@field protected name type | Protected field. | Classes |
@correlated f1, f2, ... | Fields that are always nil/non-nil together. | Nil Safety |
Generic annotations
| Annotation | Description | Guide |
|---|---|---|
@generic T | Generic type parameter on a function. | Generics |
@generic T: Class | Constrained generic. | Generics |
@param name `T` | Resolve string argument as a class name. | Generics |
@overload fun(...) | Function overload signature. | Generics |
Factory and builder annotations
| Annotation | Description | Guide |
|---|---|---|
@defclass T | Class factory function. | Classes |
@defclass T : P | Class factory with parent parameter. | Classes |
@builds-field idx type | Builder method adds a field. | Builder Pattern |
@return built | Return the accumulated built type. | Builder Pattern |
@return built : Parent | Built type with parent class. | Builder Pattern |
@built-name idx | Name the built type from a string argument. | Builder Pattern |
@built-extends | Built type inherits from receiver's built type. | Builder Pattern |
@return self | Method returns the receiver (for chaining). | Builder Pattern |
Narrowing and guard annotations
| Annotation | Description | Guide |
|---|---|---|
@type-narrows target class | Type guard function (index-based). | Type Guards |
@type-narrows ClassName | Type guard method (narrows self). | Type Guards |
@flavor-narrows flavor | Flavor guard function. | Flavor Filtering |
Metadata annotations
| Annotation | Description |
|---|---|
@alias Name type | Type alias. Supports parameters: @alias Name<K,V> V[] |
@deprecated | Mark as deprecated. |
@nodiscard | Warn if return value is ignored. |
@meta | Declaration-only file (suppresses all diagnostics). |
@diagnostic disable:code | Suppress a diagnostic inline. |
@see symbol | Cross-reference shown in hover. |
@constructor | Mark a method as the class constructor. |
@accessor name [visibility] | Set visibility for methods defined through a sub-table accessor. Guide |
Type syntax
| Syntax | Meaning |
|---|---|
string, number, boolean, nil, any | Primitives |
integer | Integer subtype of number |
table | Any table |
function | Any function |
A | B | Union |
A & B | Intersection |
T[] | Array |
T? | Optional (T | nil) |
T! | Non-nil / lateinit |
table<K, V> | Map type |
fun(a: T): R | Function type |
{f: T, g?: U} | Anonymous table shape |
"literal" | String literal type |
true, false | Boolean literal types |
params<F> | Function parameter projection (vararg only) |
returns<F> | Function return type projection |
