LuaLS / LuaLS/lua-language-server

Unable to use `@enum` or `@alias` type in table index (index signature)

Open
#2,791 5 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

I don't know if this is intended or not, but IIRC this is possible in typescript.

---@enum idx
local enum = { a = 'a', b = 'b' }

---@param tbl table<idx, string>
local function x(tbl) end

When calling x with a table (e.g. x({ | })), I expect to receive completion for a and b, but I don't get that.

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

Reproduce the LuaLS completion behavior with the enum example in the issue, starting with the table index signature and its handling of @enum and @alias types. Trace the completion path for x({}) and verify that the keys a and b are offered; done means both completions appear for the shown table type.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.