Skip to content

All Annotations

Quick reference for every annotation wowlua-ls supports. For detailed usage and examples, see the guide.

Type annotations

AnnotationDescriptionGuide
@param name typeParameter 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 ...TVariadic return — fills remaining positions with T.Multi-Return
@type typeVariable type annotation.Basic Annotations
@as typeInline expression type assertion (--[[@as T]]).Basic Annotations
@cast var [+|-]typeChange variable type: replace, add (+), remove (-).Basic Annotations

Class annotations

AnnotationDescriptionGuide
@class NameDefine a named class type.Classes
@class Name : ParentClass with inheritance.Classes
@class Name<T>Parameterized class.Generics
@class Name<T: Constraint>Parameterized class with type constraint.Generics
@enum NameEnum type — bidirectionally compatible with number.Classes
@field name typeClass field declaration.Classes
@field [K] VBracket-index field.Generics
@field private name typePrivate field.Classes
@field protected name typeProtected field.Classes
@correlated f1, f2, ...Fields that are always nil/non-nil together.Nil Safety

Generic annotations

AnnotationDescriptionGuide
@generic TGeneric type parameter on a function.Generics
@generic T: ClassConstrained generic.Generics
@param name `T`Resolve string argument as a class name.Generics
@overload fun(...)Function overload signature.Generics

Factory and builder annotations

AnnotationDescriptionGuide
@defclass TClass factory function.Classes
@defclass T : PClass factory with parent parameter.Classes
@builds-field idx typeBuilder method adds a field.Builder Pattern
@return builtReturn the accumulated built type.Builder Pattern
@return built : ParentBuilt type with parent class.Builder Pattern
@built-name idxName the built type from a string argument.Builder Pattern
@built-extendsBuilt type inherits from receiver's built type.Builder Pattern
@return selfMethod returns the receiver (for chaining).Builder Pattern

Narrowing and guard annotations

AnnotationDescriptionGuide
@type-narrows target classType guard function (index-based).Type Guards
@type-narrows ClassNameType guard method (narrows self).Type Guards
@flavor-narrows flavorFlavor guard function.Flavor Filtering

Metadata annotations

AnnotationDescription
@alias Name typeType alias. Supports parameters: @alias Name<K,V> V[]
@deprecatedMark as deprecated.
@nodiscardWarn if return value is ignored.
@metaDeclaration-only file (suppresses all diagnostics).
@diagnostic disable:codeSuppress a diagnostic inline.
@see symbolCross-reference shown in hover.
@constructorMark a method as the class constructor.
@accessor name [visibility]Set visibility for methods defined through a sub-table accessor. Guide

Type syntax

SyntaxMeaning
string, number, boolean, nil, anyPrimitives
integerInteger subtype of number
tableAny table
functionAny function
A | BUnion
A & BIntersection
T[]Array
T?Optional (T | nil)
T!Non-nil / lateinit
table<K, V>Map type
fun(a: T): RFunction type
{f: T, g?: U}Anonymous table shape
"literal"String literal type
true, falseBoolean literal types
params<F>Function parameter projection (vararg only)
returns<F>Function return type projection