Open Silent-zzz opened 6 months ago
(估計 #2501 是 duplicate)
我在搜 overload
相關 issue 時找到這個
@overload fun()
目前仍是不支援 generic 的,#2484 增加的 capture 寫法是針對 @param
目前我試出 workaround 是額外寫1段 不會執行的 if 代碼,單純用來 騙 luals 🤔
---@class frame
local frame = {}
---@class frame.button
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,
})
if false then
---@generic T
---@param name frame.`T`
---@return fun(param: table): T
---@diagnostic disable-next-line
newframe = function (name) end
end
local a = newframe 'button' {
}
newframe
variable 之中
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?
Other
Expected Behaviour
---@generic T ---@overload fun(name:frame.
T
):fun(params:table):TActual Behaviour
在fun()中class.T好像还是没办法使用
Reproduction steps
Additional Notes
No response
Log File
No response