-
-
Notifications
You must be signed in to change notification settings - Fork 357
vararg overload issue #2277
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I'm not sure that this is an appropriate use case of variable arguments. ---@param one "one"
---@param two string
---@overload fun(one: "two", two: number)
---@overload fun(one: "three", two: boolean, three: number)
local function test(one, two, three) end
test() The types of the overloads likely won't be narrowed correctly, but that issue is being tracked in #1456. |
I think my example might have confused how I am trying to use it here. I am trying to use it in a situation like
Where, the ... can be any number of args in the actual function itself but I want it to be constrained when using by the actual parameters of the given functions. (It works like this for a vararg by itself (see the first example) just not when you have param, vararg) |
I see, so it is using variable arguments, just that there are a few cases where the passed parameters should be of certain types. |
If you have a function which takes in only a vararg and you only overload it, the input type is as expected just each of the overloads:
However, if you have a param before the vararg, the input type always becomes param, ...any:
The text was updated successfully, but these errors were encountered: