Skip to content

Generics referencing generics #1161

Closed
Closed
@hahn-kev

Description

@hahn-kev

Hi, I'm working on a project where we're using a function to construct classes which allow you to pass in an inheriting class. This function to construct a class looks something like this:

---@generic TBase: table
---@generic T: TBase
---@param baseClass TBase
---@return T
function Class(baseClass, class)
end

basically the class extends the base class, however I'm not sure how to do this with generics. You can see my attempt above with ---@generic T: TBase but that doesn't work.

Is this something that's currently possible or not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat/LuaCats AnnotationsRelated to Lua Language Server Annotations (LuaCats)questionUser has a question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions