Skip to content

Fix JSDoc disappearing on destructured parameters from intersection types#3408

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-jsdoc-disappears-after-type-calculation
Draft

Fix JSDoc disappearing on destructured parameters from intersection types#3408
Copilot wants to merge 2 commits intomainfrom
copilot/fix-jsdoc-disappears-after-type-calculation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

Hovering over a destructured parameter from an intersection type lost JSDoc from constituent properties:

type X = {
    /** Description of a. */
    a: {}
}
type Y = X & { a: {} }
declare function f({ a }: Y): void
//                   ^ JSDoc "Description of a." was missing

Root cause: For intersection types with non-uniform declarations, createUnionOrIntersectionProperty sets ValueDeclaration = nil on the merged symbol (while preserving all declarations in Declarations). The hover code only checked ValueDeclaration.

Fix: In getDocumentationFromDeclaration, fall back to searching propertySymbol.Declarations when ValueDeclaration is nil or lacks JSDoc.

…ypes

When hovering over a destructured parameter from an intersection type,
JSDoc from constituent type properties was lost because the merged
property symbol has ValueDeclaration=nil when constituent declarations
differ. Now also searches through all Declarations of the property
symbol to find JSDoc.

Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/03190eda-c134-4456-aefb-bccb4e85832c

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix JSDoc disappearing after type calculation Fix JSDoc disappearing on destructured parameters from intersection types Apr 15, 2026
Copilot AI requested a review from jakebailey April 15, 2026 06:59
Comment thread internal/ls/hover.go
if foundJsdoc := getJSDocOrTag(c, decl); foundJsdoc != nil {
jsdoc = foundJsdoc
declaration = decl
break
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FWIW, Strada would actually combine the doc string for multiple declarations:
https://github.com/microsoft/TypeScript/blob/c7a0ae102dfb030c534a7bc31fbbd61a707dc9cf/src/services/jsDoc.ts#L187-L222

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot investigate

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot I have no idea what you did. You need to think about this comment

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

3 participants