lua-language-server
lua-language-server copied to clipboard
Feature Request: Extend type checking record support for positional arguments
I've been looking to add more python style function calls where you can mix both have positional arguments and keyword arguments.
It almost works already 😄 except type checking is not done for positional arguments in the caller. Inside the function it works well.
---@param args {a: integer, b: integer|nil, test: string}
local function test_no_pos(args)
-- these are correctly typed
local a = args.a
local b = args.b
end
-- everything works correctly
test_no_pos {a = "23", b = "2", test = "string"} -- correctly errors on a,b
test_no_pos({a = "23", b = "2", test = "string"}) -- correctly errors on a,b
---@param args {[1]: integer, [2]: integer|nil, test: string}
local function test_pos(args)
-- these are also correctly typed
local a = args[1]
local b = args[2]
end
test_pos {"23", "2", test = "string"} -- does not error
test_pos({"23", "2", test = "string"}) -- does not error