Skip to content

Show nested JSDoc descriptions for destructured params in signature help#63562

Open
DukeDeSouth wants to merge 2 commits into
microsoft:mainfrom
DukeDeSouth:fix/24746-signature-help-destructured-jsdoc
Open

Show nested JSDoc descriptions for destructured params in signature help#63562
DukeDeSouth wants to merge 2 commits into
microsoft:mainfrom
DukeDeSouth:fix/24746-signature-help-destructured-jsdoc

Conversation

@DukeDeSouth

Copy link
Copy Markdown

Signature help shows an empty description for object-destructured params, even when each field is documented with nested @param opts.id tags. Quick info already resolves these on hover, so I taught signature help to do the same — pull each property's doc from the parent object type and show it next to the parameter. Added a fourslash test for both a documented and an undocumented parent @param. Fixes #24746.

Signature help rendered an empty description for object-destructured
parameters whose docs live on nested `@param parent.child` tags. Resolve
each destructured property's documentation the same way quick info does on
hover (parent object type -> property -> getDocumentationComment) and show
it alongside the parameter's own doc.

Fixes microsoft#24746

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings June 16, 2026 14:40
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Jun 16, 2026
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Jun 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR enhances Signature Help so that destructured parameters surface JSDoc documentation for destructured properties (e.g., @param opts.id) alongside the parameter’s own doc, and adds a fourslash test to validate the behavior in // @checkJs scenarios.

Changes:

  • Add logic to append per-property documentation for binding-pattern (destructured) parameters in signature help output.
  • Introduce a new fourslash test covering cases with/without a parent @param opts description.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/cases/fourslash/signatureHelpJSDocDestructuredParams.ts Adds regression tests asserting signature help documentation and tags for destructured JSDoc params.
src/services/signatureHelp.ts Appends destructured-property documentation to parameter documentation in signature help.

Comment on lines +824 to +828
for (const element of declaration.name.elements) {
if (isOmittedExpression(element)) continue;
const nameNode = element.propertyName || element.name;
if (!isIdentifier(nameNode)) continue;
const propertyName = getTextOfIdentifierOrLiteral(nameNode);
Comment on lines +816 to +824
function getDestructuredParameterDocumentation(parameter: Symbol, checker: TypeChecker): SymbolDisplayPart[] {
const declaration = parameter.valueDeclaration;
if (!declaration || !isParameter(declaration) || !isBindingPattern(declaration.name)) {
return emptyArray;
}
const objectType = checker.getTypeAtLocation(declaration.name);
const types = objectType.isUnion() ? objectType.types : [objectType];
const parts: SymbolDisplayPart[] = [];
for (const element of declaration.name.elements) {
…nature help

Follow-up to review feedback: the destructured-parameter doc helper rejected
string/numeric property names (`{ "foo": x }`) because of an identifier-only
guard, and it could borrow the documentation of a same-named property for an
object-rest binding (`{ a, ...rest }`). Use isPropertyNameLiteral so quoted and
numeric names resolve while computed/private names are skipped, and skip rest
elements via dotDotDotToken. Extends the fourslash test accordingly.

Co-authored-by: Cursor <cursoragent@cursor.com>
@DukeDeSouth

Copy link
Copy Markdown
Author

Good catches — both fixed. Quoted/numeric property names now go through isPropertyNameLiteral instead of an identifier-only check, so { "foo": x } resolves its nested @param, and object-rest is skipped via dotDotDotToken so { a, ...rest } no longer borrows a same-named property's doc. Numeric { 0: x } is accepted by the guard, but the JSDoc parser doesn't bind @param x.0, so there's nothing to resolve. Added fourslash cases for both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

JSDoc comment for destructuring param: description text not displayed

2 participants