Annotations Help #1780
Unanswered
kylechui
asked this question in
General Questions
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"
} |
0 replies
---@type { [string] : string, ["KEY_NAME"]: string }
local t = {} |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?All reactions