Skip to main content

Overview

@overload defines multiple type signatures for a single function. GLuaLS uses overloads to type-check calls and infer return types from the matching overload.

Syntax


Basic overloads


Overloads with different return types


Optional parameters via overloads

Use overloads instead of optional ? parameters when parameter combinations have different types:

Method overloads

Use fun(self: ClassName, ...) to add overloads to methods:

Tips

  • The primary @param/@return annotations define the general signature
  • @overload adds specific, narrower signatures
  • GLuaLS checks overloads in order, so put more specific overloads first