Show JSDoc descriptions for JS in HTML script tags#269515
Open
magliocchetti wants to merge 3 commits into
Open
Show JSDoc descriptions for JS in HTML script tags#269515magliocchetti wants to merge 3 commits into
magliocchetti wants to merge 3 commits into
Conversation
When hovering over JavaScript code inside HTML `<script>` tags, JSDoc
descriptions and MDN reference links from TypeScript definition files
were not being displayed, although they worked correctly in .js and .ts files.
The issue was in the HTML language features server's `doHover` method in
javascriptMode.ts. It only extracted the type signature from TypeScript's
QuickInfo (info.displayParts) but ignored the documentation
(info.documentation) and tags (info.tags) containing JSDoc descriptions
and MDN links.
This commit:
- Adds displayPartsToMarkdown() helper to convert TypeScript display parts
to markdown, properly handling {@link https://...} tags for MDN references
- Modifies doHover() to include documentation and tags in hover response
- Adds test cases to verify JSDoc descriptions and MDN links are shown
Fixes microsoft#268776
Signed-off-by: Giovanni Magliocchetti <[email protected]>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the hover information displayed for JavaScript code inside HTML <script> tags by adding JSDoc descriptions and MDN reference links, bringing parity with the hover behavior in standalone .js and .ts files.
Key changes:
- Added a
displayPartsToMarkdown()helper function to convert TypeScript display parts to markdown format with link support - Enhanced the
doHover()method to include documentation and JSDoc tags in hover tooltips - Added comprehensive test coverage for the new hover functionality
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
extensions/html-language-features/server/src/modes/javascriptMode.ts |
Added markdown conversion helper and enhanced hover method to include JSDoc documentation and tags |
extensions/html-language-features/server/src/test/hover.test.ts |
Added new test suite covering hover functionality for DataTransfer, Blob, and built-in methods |
Comments suppressed due to low confidence (1)
extensions/html-language-features/server/src/modes/javascriptMode.ts:1
- The
substr()method is deprecated. Usesubstring()orslice()instead for better compatibility and future-proofing.
/*---------------------------------------------------------------------------------------------
Co-authored-by: Copilot <[email protected]>
aeschli
approved these changes
Oct 21, 2025
Contributor
|
Thanks @obrobrio2000 ! |
Collaborator
|
lint errors: |
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 #268776 - JSDoc descriptions and MDN reference links now appear when hovering over JavaScript code inside HTML
<script>tags, matching the behavior in.jsand.tsfiles.Problem
When hovering over JavaScript constructors and methods inside HTML
<script>tags, only the type signature was displayed. JSDoc descriptions and MDN reference links from TypeScript definition files (lib.dom.d.ts) were missing.Before:
After:
Root Cause
The
doHovermethod inextensions/html-language-features/server/src/modes/javascriptMode.tswas only usinginfo.displayPartsfrom TypeScript's QuickInfo response, ignoring:info.documentation- JSDoc description textinfo.tags- JSDoc tags including MDN referencesChanges
Added
displayPartsToMarkdown()helper function{@link https://...}tags for MDN referencesEnhanced
doHover()methodinfo.documentationinfo.tagsAdded test coverage
extensions/html-language-features/server/src/test/hover.test.tsTesting
Impact
Closes #268776