Overview
@type annotates a local variable, global, or table field with a specific type. Use it when GLuaLS cannot infer the type from code, such as external data or dynamic construction.
Syntax
Basic usage
Union types
Optionals (nil-able)
?:
Table types
Array types
Function types
(instance) modifier
When you use (instance), GLuaLS keeps fields added after this annotation on only that variable. It does not modify the global class definition:
(definition) modifier
When you use (definition), GLuaLS treats fields added to the variable as global additions to the class:
When to use @type vs @class
- Use
@classwhen defining a new reusable class that other code will reference by name - Use
@typewhen annotating the type of a specific local variable