lua-language-server
lua-language-server copied to clipboard
关于泛型函数
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
使用---@generic T:frame ---@return T
获取到的返回类型好像没办法继承到frame?
fun(T
):T 这种写法好像不生效,有什么类似的写法吗
Actual Behaviour
fun里好像没有办法写泛型
Reproduction steps
---@generic T:frame
---@overload fun(name:T
):fun(params:table):frame.T
local newframe = setmetatable({},{
__index = frame,
__call = function(self,name)
local class = rawget(self,name)
if class and getmetatable(class) then
return function(param)
return frame(class,param)
end
end
end,
})
---@type frame.button local a = newframe 'button' {
}
Additional Notes
有什么格式支持这种返回值吗
Log File
No response
等这个合并:https://github.com/LuaLS/lua-language-server/pull/2484