Repository navigation
Show the JSDoc written on an import x = a.x alias in hover and completions - #64657
Open
patrick kettner (patrickkettner) wants to merge 2 commits into
Open
patrick kettner (patrickkettner) wants to merge 2 commits into
patrick kettner (patrickkettner) wants to merge 2 commits into
Conversation
A comment on `import x = a.x` was never read. Hover and completion details showed the target's comment, or nothing when the target had none. 6.0 shows the alias's own comment, except on a call, where the resolved signature's documentation still wins.
Copilot started reviewing on behalf of
patrick kettner (patrickkettner)
October 6, 2026 16:14
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Merged alias symbols may read JSDoc from a non-alias declaration.
Review effort: Balanced
Findings: 1
What changed in this PR
Restores alias-authored JSDoc in hover and completion details.
Changes:
- Adds alias declaration documentation lookup with call-site precedence.
- Adds fourslash coverage and hover baseline.
| File | Description |
|---|---|
tsc/internal/ls/hover.go |
Resolves documentation from alias declarations. |
tsc/internal/fourslash/tests/hoverImportEqualsAliasJSDoc_test.go |
Tests hover and completions. |
tsc/testdata/baselines/reference/fourslash/quickInfo/hoverImportEqualsAliasJSDoc.baseline |
Records expected hover output. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| if symbol == nil || symbol.Flags&ast.SymbolFlagsAlias == 0 { | ||
| return "" | ||
| } | ||
| return getDocumentationFromDeclaration(getMappedLocation, c, symbol, core.FirstOrNil(symbol.Declarations), node, contentFormat, commentOnly) |
Author
|
@microsoft-github-policy-service agree |
On a merged symbol Declarations[0] is the namespace, so the alias comment was never read. An alias comment with no description was hiding the target's.
import x = a.x alias in hover and completions
This branch has not been deployed
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.

Fixes #64655
Analysis
getDocumentationForSymbolnever looks at the alias's own declaration. The declaration it receives is the target's, recorded while the display walk resolves the alias, anddocumentationFromAliasresolves to the target again. The parser does attach the comment to theimport f = a.fnode, it is just never read. Completion details go through the same function, so the completion entry shows the same thing.Fix
documentationFromAliasDeclarationreads the alias's own JSDoc, andgetDocumentationForSymboltries it right after the call-signature documentation. At a call site the recorded declaration is the resolved signature's and keeps priority, so hover onb.f()still shows the declaration's comment. This matches 6.0'ssymbolDisplay.I tried letting
documentationFromSignaturereturn docs for any resolved-signature declaration first. That movedquickInfoCommentsFunctionExpressionaway from what 6.0 shows, so I dropped it.quickInfoOnInternalAliasesnow gets its documentation right but stays skipped, since its display text still differs from 6.0.Copilot Checklist
I successfully ran the applicable command at the end of my session, and it completed without error:
I used Claude Code to write the patch and the test, and I have read and reviewed both.