LuaLS / LuaLS/lua-language-server

Is there a way to specify type aliases for variadic arg functions

Open
#3,252 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

Is there any way to achieve proper inference of variadic arguments using aliases?

Image

a should be fun(a: table, b: string, c: integer): boolean but instead it's fun(...: table): boolean

I've also tried but it didn't work

--- @alias Predicate1<A> fun(a: A): boolean
--- @alias Predicate2<A, B> fun(a: A, b: B): boolean
--- @alias Predicate3<A, B, C> fun(a: A, b: B, c: C): boolean
--- @alias Predicate4<A, B, C, D> fun(a: A, b: B, c: C, d: D): boolean

--- @alias Predicate<A, B, C, D>
--- | Predicate1<A>
--- | Predicate2<A, B>
--- | Predicate3<A, B, C>
--- | Predicate4<A, B, C, D>

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

Start with the provided LuaLS reproduction and compare the inferred type with the expected variadic function signature. Trace the Predicate1–Predicate4 alias examples to determine the current limits of generic and variadic alias inference; done means establishing whether supported syntax or a broader inference change is required.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.