Skip to content

Fix deprecated JSDoc tags not showing for default imports #22

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 14, 2025

When hovering over a default import identifier, the TypeScript language service was not displaying JSDoc deprecation information from the corresponding export default statement. This issue affected IDE features like quick info tooltips.

Problem

Consider this code:

// mod.ts
/** @deprecated please don't use this */
export const depr = 'deprecated';

/** Please use this one */
export const notDeprecated = 'not deprecated';

/** @deprecated please import { notDeprecated } instead */
export default notDeprecated;

// index.ts
import defaultExport, { depr, notDeprecated } from './mod.js';

When hovering over defaultExport, the quick info tooltip would only show:

import defaultExport

But it should also show the deprecation message:

import defaultExport
@deprecated please import { notDeprecated } instead

Named imports like depr worked correctly and showed their deprecation information.

Root Cause

The issue was in the symbol display logic in src/services/symbolDisplay.ts. For default imports:

  1. The alias symbol has SymbolFlags.Alias but not SymbolFlags.ExportValue (unlike named imports which have both)
  2. getAliasedSymbol() returns the symbol for the exported value (notDeprecated)
  3. The JSDoc we want is on the ExportAssignment node, not on the resolved symbol
  4. The existing logic only retrieved JSDoc from the resolved symbol, missing the export assignment's JSDoc

Solution

Added logic to detect default imports using symbol flags and extract JSDoc from the corresponding export assignment:

  • Default imports: (flags & SymbolFlags.Alias) && !(flags & SymbolFlags.ExportValue)
  • Named imports: (flags & SymbolFlags.Alias) && (flags & SymbolFlags.ExportValue)

For default imports, the code now:

  1. Finds the export assignment in the source file that exports the resolved symbol as default
  2. Extracts JSDoc comments and tags using getJSDocCommentsAndTags()
  3. Uses the export assignment's JSDoc instead of the resolved symbol's JSDoc

Addressing #20.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Fix Fix deprecated JSDoc tags not showing for default imports Jul 14, 2025
@Copilot Copilot AI requested a review from RyanCavanaugh July 14, 2025 23:37
Copilot finished work on behalf of RyanCavanaugh July 14, 2025 23:37
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.

2 participants