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

generic param no hint

Open sundream opened this issue 1 year ago • 2 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?

Completion

Expected Behaviour

---删除物品
---@class pb.S2C_DelItem
---@field itemId integer 物品id

---发送协议到客户端
---@generic T
---@param cmd pb.`T` 命令名
---@param args T
---@return T
function sendToClient(cmd, args)
    return nil
end

local ret = sendToClient("S2C_DelItem",{
    itemId = 1,                 -- 无法推断出args为pb.S2C_DelItem类型,输入itemId无字段类型提示
})

ret.itemId                       -- 返回值能推断出为pb.S2C_DelItem类型,输入itemId有字段类型提示

47d177bc16d5104b26100d38e2e7a69 4373b0763922e91aab1d34326241dd1

Actual Behaviour

能正确推断出泛型参数类型并有代码提示

Reproduction steps

如上代码

Additional Notes

No response

Log File

No response

sundream avatar Aug 15 '24 07:08 sundream