Skip to content

How to annotate table that uses indexing and not field names. #2809

Answered by tomlau10
vnaoScriptHub asked this question in Q&A
Discussion options

You must be logged in to vote

use the [index] syntax

---@class VersionInfo
VersionInfo  = {
    ---@class FileVersion
    ---@field [1] integer Major version.
    ---@field [2] integer Minor version.
    ---@field [3] integer Revision number.
    ---@field [4] integer Build number.
    FileVersion = {}
}

local a = VersionInfo.FileVersion[1]    --< integer
local b = VersionInfo.FileVersion[5]    --< unknown

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@vnaoScriptHub
Comment options

Answer selected by vnaoScriptHub
Comment options

You must be logged in to vote
3 replies
@tomlau10
Comment options

@tomlau10
Comment options

@vnaoScriptHub
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants