LuaLS / lua-language-server

A language server that offers Lua language support - programmed in Lua
https://luals.github.io
MIT License
3.12k stars 289 forks source link

Typed field overrides the type of other fields #2711

Open halflifefan opened 2 weeks ago

halflifefan commented 2 weeks ago

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

local my_class: my_class {
    my_function: function,
    [string]: unknown,
}

Actual Behaviour

local my_class: my_class {
    my_function: function|unknown,
    [string]: unknown,
}

Reproduction steps

---@class my_class
---@field [string] unknown
local my_class = {}

function my_class:my_function() end

Additional Notes

No response

Log File

No response

halflifefan commented 2 weeks ago

Workaround: create a base class with typed fields.