LuaLS / LuaLS/lua-language-server
关于泛型函数
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
### 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_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generic annotation and setmetatable reproduction in the issue, then trace how the type checker handles `---@generic`, `---@overload`, and `fun` return types. Done means either the existing annotation format correctly infers `frame.button` or the supported syntax and its limitations are clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100