Skip to content

Fix and simplify JSDoc handling for binding elements#4029

Open
ahejlsberg wants to merge 2 commits into
mainfrom
fix-3405
Open

Fix and simplify JSDoc handling for binding elements#4029
ahejlsberg wants to merge 2 commits into
mainfrom
fix-3405

Conversation

@ahejlsberg
Copy link
Copy Markdown
Member

This PR fixes our quick info JSDoc handling for destructuring of intersections and also simplifies our implementation of quick info JSDoc for binding elements.

Note that Corsa only displays JSDoc from one source property whereas Strada displays JSDoc from all source properties. It is generally true that Corsa only displays JSDoc from one source, which often is preferable to avoid duplication. We could consider displaying JSDoc from multiple sources, though that would be a separate PR.

Fixes #3405.

Copilot AI review requested due to automatic review settings May 22, 2026 20:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes QuickInfo/hover JSDoc retrieval for binding elements produced by object destructuring when the source type is an intersection (e.g. type Y = X & { a: {} }), and centralizes/simplifies the binding-element JSDoc lookup logic within the shared getJSDocOrTag helper.

Changes:

  • Move binding-element JSDoc fallback logic from getDocumentationFromDeclaration into getJSDocOrTag, resolving docs via the destructured property symbol from the binding pattern’s type.
  • Remove the now-unneeded helper findPropertyInType.
  • Add new fourslash coverage (and reference baselines) for destructuring from intersection types in both parameter and variable-binding scenarios.

Reviewed changes

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

File Description
internal/ls/hover.go Centralizes binding-element JSDoc fallback in getJSDocOrTag to fix intersection destructuring hover docs and simplify hover documentation plumbing.
internal/fourslash/tests/destructuredIntersectionJSDoc_test.go Adds fourslash tests covering parameter and variable destructuring from an intersection type where property JSDoc should be shown.
testdata/baselines/reference/fourslash/quickInfo/destructuredIntersectionJSDoc.baseline New hover baseline validating JSDoc appears for a destructured parameter from an intersection type.
testdata/baselines/reference/fourslash/quickInfo/destructuredIntersectionJSDocVariable.baseline New hover baseline validating JSDoc appears for a destructured variable binding from an intersection type.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSDoc disapprears after type calculation

2 participants