Show nested JSDoc descriptions for destructured params in signature help#63562
Show nested JSDoc descriptions for destructured params in signature help#63562DukeDeSouth wants to merge 2 commits into
Conversation
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>
There was a problem hiding this comment.
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 optsdescription.
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. |
| 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); |
| 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>
|
Good catches — both fixed. Quoted/numeric property names now go through |
Signature help shows an empty description for object-destructured params, even when each field is documented with nested
@param opts.idtags. 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.