microsoft / microsoft/TypeScript

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

Open
#44,932 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs Proposal Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the JSDoc @param parsing entry point and compare the reported AST for [somebody=John Doe] with the requested defaultValue node. Done means non-TS default expressions are preserved as default values, the description no longer includes the closing bracket or parameter-name text, and coverage verifies the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.