-
-
Notifications
You must be signed in to change notification settings - Fork 391
Closed
Description
At the moment when u define an enum like this in 1 file (ill refer to this as EnumFile.lua)
---@enum MyEnum
local myEnum = {
entry1 = 1
}
return myEnumand you require it in another file (main.lua)
---@type MyEnum
local myEnum = require("EnumFile.lua")
local enumEntry = myEnum.entry1 -- errorwhat i expect it to do instead with something like ---@type is to return the enum object (the table with the entries), not any entry within the enum. if this is intended behaviour then i think the enum system is kind of bad.
i do have a solution, which doesnt work but is my feature request
when u ---@type a variable, and u want to set the type to the Enum object itself (not any entry of the enum) then add something like [] at the end of the type (if its an enum) to signal it being an enum object, and without [] it just being an entry within the enum
here is an example
---@type MyEnum[]
local myEnum = require("EnumFile.lua")
---@type MyEnum
local enumEntry = myEnum.entry1Metadata
Metadata
Assignees
Labels
No labels