Skip to main content

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)

or using the shorthand ?:

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 @class when defining a new reusable class that other code will reference by name
  • Use @type when annotating the type of a specific local variable