Skip to content

Defining types #1479

@RomanSpector

Description

@RomanSpector

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions