Repository navigation
Fix signature help docs for const function types - #64949
Open
Madwolf Studios (MadalinWolf) wants to merge 2 commits into
Open
Madwolf Studios (MadalinWolf) wants to merge 2 commits into
Madwolf Studios (MadalinWolf) wants to merge 2 commits into
Conversation
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Parameter and imported-constant documentation remain missing, and the fallback can copy descriptions between unrelated overloads.
3 open issues
What changed in this PR
This PR addresses #64937 by adding a documentation fallback for function-typed const declarations in the language server’s signature help.
Changes:
- Preserves signature-level documentation lookup, then searches call-target declarations when no description is found.
- Adds a fourslash regression test and baseline for a documented function-typed constant.
| File | Description |
|---|---|
tsc/testdata/baselines/reference/fourslash/signatureHelp/signatureHelpCommentsConstFunctionType.baseline |
Records the signature and recovered JSDoc description. |
tsc/internal/ls/signaturehelp.go |
Adds the call-target documentation fallback. |
tsc/internal/fourslash/tests/signatureHelpCommentsConstFunctionType_test.go |
Adds the signature-help regression fixture. |
Review effort: Balanced
- Skip function-like declarations in the binding-level documentation fallback so an undocumented overload never inherits documentation from a different overload. - Resolve import aliases via documentationFromAlias when the call target is a named import, so imported const function types show documentation. - Resolve matching JSDoc @PARAM tags from the call target's (or its alias target's) non-function-like declarations when a parameter has no documentation of its own, covering const function types. Adds regression tests for overload precedence and imported const function types, and updates baselines accordingly.
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.

Summary
Fixes #64937
Fixes missing JSDoc documentation in signature help for a
constdeclaration with a function type annotation.Implementation
Signature help previously retrieved documentation from the candidate signature's declaration. For a function type annotation such as
declare const addOne: (value: number) => number, this declaration may not contain the JSDoc comments attached to theconstdeclaration itself.This change preserves the existing documentation lookup and adds a fallback that searches the call target symbol's declarations when documentation is unavailable from the candidate signature's declaration.
Tests
TestSignatureHelpCommentsConstFunctionTypeto cover signature help for aconstfunction with JSDoc comments.go test ./internal/fourslash/tests -run '^TestSignatureHelpCommentsConstFunctionType$' -count=1Result: PASS.
The test confirms that the signature help displays the expected function signature and main JSDoc description.