Skip to content

Support enums with runtime values #1411

Closed
@Feez

Description

@Feez

I have written an LuaDoc api documentation file for a library of mine, and I currently cannot abstract away the values of an enum that makes use of the ---@enum annotation. I've tried forcing the enum values to not be known before runtime, but it seems the annotation does not support such a case.

We can see that intellisense is happy to suggest each enum variation for when the enum values are known before runtime:
image

However, if we provide the enum values as some runtime value, it does not suggest anything:
image

Ideally, it would still suggest enum.A, enum.B, and enum.C.

An alternative solution may be to support an enum defined fully via LuaDoc as such:

---@enum TestEnum
---@field A number
---@field B number
local enum = {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions