Skip to content

[Annotations] How to set a default value for a function parameter? #2349

Open
@punkochel

Description

@punkochel
---@param name string
---@param age? number
function addPerson(name, age)
    age = age or 18
end

How can I specify that the age parameter is optional and has a default value of 18?
So that in the popup-menu it looks something like this:

function addPerson(name: string [,age = 18: number])

Or

function addPerson(name: string, age = 18: number)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeat/LuaCats AnnotationsRelated to Lua Language Server Annotations (LuaCats)feat/type checkRelated to the type checking feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions