lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Support for generic classes

Open K4rakara opened this issue 4 years ago • 6 comments

Describe the bug Despite being mentioned in luanalysis, generic classes are not supported by this language server.

Screenshots image

Environment:

  • OS: Arch Linux
  • Client: VSCode

K4rakara avatar Oct 15 '21 01:10 K4rakara

Just some test cases:

---@class Array<T>: { [integer]: T }

---@type Array<string>
local arr = {}

-- correctly warns that I am assigning a boolean to a string
arr[1] = false

-- no warning despite indexing with a string instead of an integer
arr["foo"] = "bar"

-- correctly does not warn as I am following the type correctly
arr[3] = "Correct"
---@class Dictionary<T>: { [string]: T }

---@type Dictionary<boolean>
local dict = {}

-- no warning despite indexing with a number
dict[1] = "incorrect"

-- no warning despite assigning a string
dict["foo"] = "bar?"

-- correctly does not warn as I am following the type correctly
dict["correct"] = true

carsakiller avatar Feb 20 '23 04:02 carsakiller

Ran into this today as well 😞.

GiuseppeIII avatar Jun 25 '23 23:06 GiuseppeIII

Any update on this? This feature would be amazing!

b0o avatar Mar 31 '24 05:03 b0o

This has cropped up as an issue that's making modularity difficult. Would love to see it fixed.

A1steaksa avatar Apr 20 '24 17:04 A1steaksa

Is there any fix for Undefined type or alias yet?

Image

Because it looks like it works correctly in type definitions:

Image

vaderkos avatar Aug 31 '25 11:08 vaderkos

I am also experiencing this issue on arch, using neovim with the mason lua-language-server language server.

Image

Sampleeeee avatar Oct 15 '25 01:10 Sampleeeee