lua-language-server
                                
                                 lua-language-server copied to clipboard
                                
                                    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?
Other
Expected Behaviour
---@generic T
---@overload fun(name:frame.T):fun(params:table):T
Actual Behaviour
在fun()中class.T好像还是没办法使用
Reproduction steps
- Go to '...'
- Click '...'
- See error '...'
Additional Notes
No response
Log File
No response
(估計 #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' {
}
- 這樣能將帶 generic 的 function type union 到 newframevariable 之中