Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for generic classes #734

Open
K4rakara opened this issue Oct 15, 2021 · 4 comments
Open

Support for generic classes #734

K4rakara opened this issue Oct 15, 2021 · 4 comments
Labels
enhancement New feature or request feat/generic Related to generic emulation feature feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats)

Comments

@K4rakara
Copy link

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
@sumneko sumneko added feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats) enhancement New feature or request labels Oct 15, 2021
@carsakiller carsakiller added the feat/generic Related to generic emulation feature label Jul 28, 2022
@carsakiller
Copy link
Collaborator

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

@GiuseppeIII
Copy link

Ran into this today as well 😞.

@b0o
Copy link

b0o commented Mar 31, 2024

Any update on this? This feature would be amazing!

@A1steaksa
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat/generic Related to generic emulation feature feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats)
Projects
None yet
Development

No branches or pull requests

6 participants