how can i annotate a function that returns optional multiple value #2136
-
hi folks, i'm always having such itch:
the only way i figured out to annotate the return value of because the above function returns either |
Beta Was this translation helpful? Give feedback.
Answered by
carsakiller
May 29, 2023
Replies: 1 comment 3 replies
-
The best way to approach this is maybe with an ---@return number
---@return number
---@overload fun(): nil
local function foo()
if "nice day" then
return 1, 2
else
return
end
end
local one, two = foo() |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
haolian9
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The best way to approach this is maybe with an
@overload
, but I am still not sure that the type will be narrowed properly in more complex cases: