Skip to content

Combining generic classes and variadics #787

@Polanas

Description

@Polanas

I've been trying to write a function that accepts a number of Wrapped<T>'s and returns T's, but couldn't get it to work.

---@class Wrapper<T>

---@generic T
---@param ... Wrapper<T>...
---@return T...
function unwrap(...) end

---@type Wrapper<int>, Wrapper<string>
local a, b

--should be int, string
local b, c = unwrap(a, b)

Instead a warning is thrown: expected 0 parameters but found 2 [redundant-parameter].
Can something like this be done with current variadics implementation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions