Skip to content

JSDoc param tag's default value parsing should support non-TS expressionsΒ #44932

Open
@atanasster

Description

@atanasster

Suggestion

probably related to #44930 but a different use case. default values on @param: https://jsdoc.app/tags-param.html

πŸ” Search Terms

jsdoc param default value

⭐ Suggestion

Please allow for default value params parsing

/**
 * @param {string} [somebody=John Doe] - Somebody's name.
 */
export function sayHello(somebody) {
}

currently parses to tags:

[
  {
    name: "param",
    text: [
      {
        text: "somebody",
        kind: "parameterName"
      },
      {
        text: " ",
        kind: "space"
      },
      {
        text: "Doe] - Somebody's name.",
        kind: "text"
      }
    ]
  }
]

possibly add a new node

{
    text: "John Doe",
    kind: "defaultValue"
  },

and clean up the description from

{
  text: "Doe] - Somebody's name.",
  kind: "text"
}

to

{
  text: "- Somebody's name.",
  kind: "text"
}

p.s. it mighy also be worth in general to clean up parameter descriptions text from the leading hyphen

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions