Skip to content

How to write annotation for an array that each element is a union of two types? #2164

Closed Answered by carsakiller
linrongbin16 asked this question in Q&A
Discussion options

You must be logged in to vote

There are multiple ways that this could be typed:

---@type (string|integer)[]
local a = {}
---@type table<integer, string | integer>
local a = {}
---@alias Array<T> T[]
---@type Array<string | integer>
local a = {}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@carsakiller
Comment options

@linrongbin16
Comment options

Answer selected by linrongbin16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats)
2 participants