-
Notifications
You must be signed in to change notification settings - Fork 747
Fix missing JSDoc comments on destructured interface properties #2195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jakebailey <[email protected]>
Co-authored-by: jakebailey <[email protected]>
Co-authored-by: jakebailey <[email protected]>
Co-authored-by: jakebailey <[email protected]>
Co-authored-by: jakebailey <[email protected]>
There was a problem hiding this 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
getDocumentationFromDeclarationto detect binding elements and retrieve documentation from the interface property - Added helper function
findPropertyInTypeto 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 |
jakebailey
left a comment
There was a problem hiding this 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.
Summary
Fixed the issue where destructured interface members were not showing inherited JSDoc comments when hovering.
Changes Made:
getDocumentationFromDeclarationininternal/ls/hover.goto detect binding elements (destructured variables) and retrieve documentation from the corresponding property in the source typefindPropertyInTypeto handle union types properly (simplified usingIsUnion()andTypes()methods)Testing:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.