Skip to main content

Overview

@return declares the type or types a function returns. Lua functions can return multiple values, so add one @return line for each return value.

Syntax


Basic usage


Multiple return values


Optional return values

Or with ? shorthand:

Default return values

You can specify a default value for a return type using the =value syntax:
This tells GLuaLS what the value defaults to.
The default value must come directly after the type, before the name:
  • ---@return boolean=false success — ✅ Correct.
  • ---@return boolean success=false — ❌ Incorrect. (This makes =false part of the description instead).

Generic return values


Return from string-template generic capture

Use `T` for string-literal class names. Plain T captures value type (string), not class type. Quick rule:
  • T returns value-based types ("x" -> string)
  • `T` returns class/type names from string literals ("sent_npc" -> sent_npc)

Function return values


(instance) modifier

This annotation is for internal use. Most projects do not need this modifier.
When a function returns (instance), GLuaLS keeps fields and methods on that returned variable. It does not add them to the global class:
Use this for factory functions that return panels or entities with custom methods.

(definition) modifier

This annotation is for internal use. Most projects do not need this modifier.
When a function returns (definition), GLuaLS registers fields on the returned variable as global class fields: