lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Defining types

Open RomanSpector opened this issue 3 years ago • 0 comments

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Type Checking

Expected Behaviour

image

image

Actual Behaviour

image

image

Reproduction steps

---@alias Test
---| "Test1"
---| "Test2"
---| "Test3"

---@class Car
---@field a number
---@field b number
local Car = {};

---@return boolean
function Car:c() end

---@type table<Test, fun(car: Car): boolean>
local CONDITIONS =
{
    ["Test1"] = function(car) return car:c() end,
    ["Test2"] = function(car) return car:c() end,
    ["Test3"] = function(car) return car:c() end,
}

local conditions = CONDITIONS["Test1"];

Additional Notes

No response

Log File

No response

RomanSpector avatar Aug 18 '22 11:08 RomanSpector