Replies: 2 comments 1 reply
-
Hm, I thought something like this would work: ---@alias Headers
---| 'Authorization'
---| string
---@type table<Headers, string>
local headers = {} Or like this: ---@alias Headers
---| 'Authorization'
---@type table<Headers | string, string>
local headers = {} But neither seem to provide type checking nor completion for the defined headers. This should probably me made an issue instead. In fact, even this doesn't warn me: ---@type table<number, string>
local headers = {
str = "hello"
} |
Beta Was this translation helpful? Give feedback.
-
---@type { [string] : string, ["KEY_NAME"]: string }
local t = {} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
A bit of a strange question, but is there a way to specify a table of strings that necessarily contains a certain key? For example, we may have
table<string, string>
or{ KEY_NAME: string }
. Is there a way to combine these two so I have completion forKEY_NAME
, but also enforce that the rest of the table only contains strings as keys?Beta Was this translation helpful? Give feedback.
All reactions