Skip to content

关于泛型函数 #2501

@Silent-zzz

Description

@Silent-zzz

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

QQ截图20240128083839

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions