table type

Note

Use table<KEY_TYPE, VALUE_TYPE> to specify that a variable’s type is a table(a.k.a. dictionary, map) type

  • Full format:
---@type table<KEY_TYPE, VALUE_TYPE>
  • Examples:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    ---@type table<string, Car>
    local dict = {}
    
    local car = dict['key']
    -- car. and you'll see completion
    
    for key, car in pairs(dict) do
        -- car. and you'll see completion
    end
    
Fork me on GitHub