I would like to ask if is somehow possible to set type of the params of the functions in table in one place.
Here is an example of the table:
local test =
{
[0] = function (var) <some stuff> end,
[1] = function (var) <some other stuff> end,
}
I know that the variable "var" will always be for example an integer. So I wanted to add ---@type table<integer, fun(var: integer)> above the table "test" like this:
---@type table<integer, fun(var: integer)>
local test =
{
[0] = function (var) <some stuff> end,
[1] = function (var) <some other stuff> end,
}
Unfortunatelly this does not work and IDE does not know that var is an integer. I am using VS Code.
I have a workaround for this if I specify param for each function like this:
local test =
{
---@param var integer
[0] = function(var) <some stuff> end,
---@param var integer
[1] = function(var) <some other stuff> end,
}
But that's kinda annoying and I think it would be better if it could be solved somehow by adding some annotation above the table in one place.
Hello,
I would like to ask if is somehow possible to set type of the params of the functions in table in one place. Here is an example of the table:
I know that the variable "var" will always be for example an integer. So I wanted to add ---@type table<integer, fun(var: integer)> above the table "test" like this:
Unfortunatelly this does not work and IDE does not know that var is an integer. I am using VS Code. I have a workaround for this if I specify param for each function like this:
But that's kinda annoying and I think it would be better if it could be solved somehow by adding some annotation above the table in one place.
Thanks