Skip to content

how can i annotate a function that returns optional multiple value #2136

Answered by carsakiller
haolian9 asked this question in Q&A
Discussion options

You must be logged in to vote

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:

---@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()

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@haolian9
Comment options

@carsakiller
Comment options

@haolian9
Comment options

Answer selected by haolian9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants