Skip to content

Inconsistent "question mark" sign placement with optional parameters #2029

@ArmoredPony

Description

@ArmoredPony

let's say I have a function with two optional parameters

---@param foo? string
---@param bar string?
local function func(foo, bar) end

foo parameter has its ? after its name and bar after its type.
When I hover my mouse over the function name, the ? sign appears after names of the parameters
image
But when I hover it over a parameter name, this sign appears after type of the parameters
image
It doesn't matter where I put this sign in ---@param annotation: after name or after type.

Same with classes

---@class Cls
---@field foo string?
---@field bar? string
local cls = {}
cls.foo = nil
cls.bar = nil

image
image
image

Is this inconsistency by design? Does it mean something? If not, I'd prefer always seeing it at the same place. May be always after a type.
This issue is pretty minor but I still wanted to report about it. Screenshots are from VS Code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    as designedFunctioning as intended, will not be modifiedquestionUser has a question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions