Skip to content

compiler api: jsdoc parse optional paramsΒ #44930

@atanasster

Description

@atanasster

Suggestion

Optional jsdoc parameters are currently lost on @param: https://jsdoc.app/tags-param.html

πŸ” Search Terms

jsdoc optional params

⭐ Suggestion

Please allow for optional params parsing

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

currently parses to tags:

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

Possible suggestions:

  • add a node kind: optional,
  • or keep the square brackets around the name so users have a way to parse the optional parameter name:
 {
    text: "[somebody]",
    kind: "parameterName",
  },

πŸ“ƒ Motivating Example

example test to reproduce https://github.com/atanasster/ts-issues/blob/master/tests/optional-param.test.ts

Metadata

Metadata

Assignees

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions