LuaLS / LuaLS/lua-language-server

feature: support generics in function type format

Open
#1,170 3 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement feat/generic feat/LuaCats Annotations
Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

Currently, the only way to document generic functions is to use `@generic`. and it's not possible to use them in overloads or fields.

The following examples are invalid:

```lua
---@generic T
---@param arg1 string
---@param arg2 T
---@return T
---@overload fun(arg2: T) <- Undefined type or alias `T`.
local function foo(arg1, arg2)
return arg2 or arg1
end
```

```lua
---@class Foo
---@field bar fun(arg:T): T <- `(` expected.
local Foo = {}
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. Start by locating the parsing and type-resolution paths for @generic, @overload, and function types, then compare them with the two Lua examples. Done means generic type parameters resolve inside overload signatures and field function types without the reported diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
compilers, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.