Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 3, 2025

  • Understand the issue: Destructured interface members lack inherited JSDoc comments
  • Create a fourslash test to reproduce the issue
  • Verify the test fails as expected
  • Research the TypeScript reference implementation
  • Identify the fix needed: Add special handling for binding elements in hover.go
  • Implement the fix to handle binding elements
  • Run tests to verify the fix works
  • Test renamed destructuring edge case
  • Run linters and build
  • Run broader test suite
  • Update baselines
  • Address code review feedback
  • Final verification with CodeQL
  • Simplify code using IsUnion() and Types() methods

Summary

Fixed the issue where destructured interface members were not showing inherited JSDoc comments when hovering.

Changes Made:

  1. Modified getDocumentationFromDeclaration in internal/ls/hover.go to detect binding elements (destructured variables) and retrieve documentation from the corresponding property in the source type
  2. Added a helper function findPropertyInType to handle union types properly (simplified using IsUnion() and Types() methods)
  3. Updated function signature to pass symbol and location for proper context
  4. Added comprehensive tests for both basic and renamed destructuring
  5. Updated 4 baseline tests that now correctly show JSDoc comments

Testing:

  • All existing tests pass
  • New tests added for destructuring with JSDoc
  • Baseline tests updated to reflect correct behavior
  • No security vulnerabilities detected by CodeQL
Original prompt

This section details on the original issue you should resolve

<issue_title>Destructured interface members lack inherited JSDoc comments</issue_title>
<issue_description>### Extension Version

0.20251203.1

VS Code Version

1.106.3

Operating system Version

Ubuntu x86-64, running via Windows 11 inside WSL

Steps to reproduce

  1. Copy this MRE:
    interface FooBar {
        /** foo comment */
        foo: number;
        /** bar comment */
        bar: string;
        /** baz comment */
        baz: string;
    }
    
    declare const fubar: FooBar;
    
    const {foo, bar, baz} = fubar;
  2. hover over properties
  3. no comments
Image

Issue

Should have hovers, as is present in normal typescript</issue_description>

<agent_instructions>Make a fourslash test in ./internal/fourslash/tests first; see internal/fourslash/tests/hoverAliasInImportedFile_test.go for an example.

Remember that you have a reference hover implementation in the submodule to cross compare.

You can use print debugging with go test -v as well.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix issue with inherited JSDoc comments in destructured members Fix missing JSDoc comments on destructured interface properties Dec 3, 2025
Copilot AI requested a review from jakebailey December 3, 2025 18:17
Copilot finished work on behalf of jakebailey December 3, 2025 18:17
Copilot AI requested a review from jakebailey December 3, 2025 18:41
Copilot finished work on behalf of jakebailey December 3, 2025 18:41
Copilot finished work on behalf of jakebailey December 3, 2025 19:10
Copilot AI requested a review from jakebailey December 3, 2025 19:10
@jakebailey jakebailey marked this pull request as ready for review December 3, 2025 19:12
Copilot AI review requested due to automatic review settings December 3, 2025 19:12
Copilot finished reviewing on behalf of jakebailey December 3, 2025 19:14
Copy link
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 an issue where destructured interface members were not showing their inherited JSDoc comments when hovering over them in the editor. The fix adds special handling for binding elements (variables created from destructuring) in the hover implementation to retrieve documentation from the corresponding property in the source type.

Key Changes

  • Modified getDocumentationFromDeclaration to detect binding elements and retrieve documentation from the interface property
  • Added helper function findPropertyInType to handle union types when searching for properties
  • Updated function signature to pass symbol and location context
  • Added comprehensive tests for both basic and renamed destructuring scenarios

Reviewed changes

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

File Description
internal/ls/hover.go Added binding element detection logic and helper function to find property documentation in source types, updated function signature
internal/ls/signaturehelp.go Updated call to getDocumentationFromDeclaration with new signature
internal/fourslash/tests/destructuredInterfaceJSDoc_test.go Added new tests for destructured interface JSDoc comments, including renamed properties
testdata/baselines/reference/fourslash/quickInfo/*.baseline Updated 4 baseline tests to correctly show JSDoc comments for destructured properties

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

I think this is not unreasonable; it is the same code, but things are shifted around in the Go version.

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.

Destructured interface members lack inherited JSDoc comments

2 participants