Skip to content

Display JSDoc documentation in Quick Info #1018

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

Merged
merged 8 commits into from
Jun 3, 2025
Merged

Conversation

ahejlsberg
Copy link
Member

With this PR we now include JSDoc documentation when hovering over code elements:

image

This PR also fixes several language service crashes, including #992.

Fixes #992.

@ahejlsberg ahejlsberg requested review from Copilot, jakebailey and sandersn and removed request for Copilot June 2, 2025 22:56
Copy link
Contributor

@Copilot Copilot AI left a 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 enhances the hover functionality by displaying enhanced Quick Info that includes JSDoc documentation and fixes several language service crashes (fixes #992). Key changes include updates to the parser for JSDoc template tags, refactoring of hover info generation to integrate JSDoc comments, and various adjustments in the checker, AST, and binder modules to accommodate new JSDoc behaviors.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/parser/reparser.go Simplifies iteration over JSDoc template tag type parameters.
internal/ls/hover.go Introduces Quick Info formatting that incorporates JSDoc details in hover information.
internal/checker/utilities.go Removes redundant helper in favor of the AST-level implementation.
internal/checker/types.go Adds a new formatting flag for call-style signature output.
internal/checker/printer.go Adjusts the condition for formatting constructor signatures for better call-style support.
internal/checker/checker.go Replaces legacy helper calls with AST-level ones and updates type alias link assignment.
internal/binder/binder.go Reorders calls to set JSDoc parents to streamline AST binding.
internal/ast/utilities.go Introduces a new AST helper to check property access contexts.
internal/ast/ast.go Updates JSDoc template tag handling to expose type parameters as a public field.
internal/api/encoder/encoder.go Uses direct field access for JSDoc template tag type parameters for encoding.
Comments suppressed due to low confidence (3)

internal/checker/checker.go:21557

  • The change from 'declaredTypeLinks' to 'typeAliasLinks' appears intentional for handling type aliases; please confirm that this adjustment correctly aligns with the semantic requirements for unresolved type handling.
c.typeAliasLinks.Get(result).declaredType = c.unresolvedType

internal/binder/binder.go:1577

  • [nitpick] The repositioning of 'b.setJSDocParents(node)' in the binder function changes the order of JSDoc parent binding relative to child binding; please verify that the new ordering covers all necessary nodes.
b.setJSDocParents(node)

internal/checker/printer.go:279

  • [nitpick] The updated condition for determining a constructor excludes call-style signature formatting when the WriteCallStyleSignature flag is set; please ensure this change correctly reflects the desired behavior for constructor signature output.
isConstructor := signature.flags&SignatureFlagsConstruct != 0 && flags&TypeFormatFlagsWriteCallStyleSignature == 0

@jakebailey
Copy link
Member

I was bad and #992 was an issue that should have been two; I assume the crash is what's fixed, not the actual bad type error?

@ahejlsberg
Copy link
Member Author

I was bad and #992 was an issue that should have been two; I assume the crash is what's fixed, not the actual bad type error?

Right, this PR just fixes the crash.

@ahejlsberg ahejlsberg enabled auto-merge June 2, 2025 23:37
@ahejlsberg ahejlsberg added this pull request to the merge queue Jun 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 2, 2025
@jakebailey jakebailey added this pull request to the merge queue Jun 3, 2025
@jakebailey
Copy link
Member

ATA test flake :(

Merged via the queue into main with commit a9843d9 Jun 3, 2025
23 checks passed
@jakebailey jakebailey deleted the quick-info-jsdoc branch June 3, 2025 00:20
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.

Bad error in JSDoc type, crashes hover
2 participants