Fix and simplify JSDoc handling for binding elements#4029
Open
ahejlsberg wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
getDocumentationFromDeclarationintogetJSDocOrTag, 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.