@class class declaration annotation

Note

EmmyLua use @class to simulate classes in OOP, supporting inheritance and fields

../_images/class1.png
  • Full format:
--@class MY_TYPE[:PARENT_TYPE] [@comment]
  • Target:

    • local variables
    • global variables
  • Examples:

    1
    2
    3
    4
    5
    ---@class Car : Transport @define class Car extends Transport
    local cls = class()
    
    function cls:test()
    end
    
  • Descriptions:

    Sepcifies variable cls is class Car, so we can use @type to specify other variables’ types as Car, which can improve completion and other functionality.

Fork me on GitHub