Skip to content

Add support for JSDoc @implements tag in reparser #1104

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 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 9, 2025

This PR adds support for the JSDoc @implements tag by implementing the missing case in the reparser to create synthetic heritage clauses.

Problem

The JSDoc @implements tag was already being parsed correctly in jsdoc.go, but the reparser in reparser.go was missing the case to handle KindJSDocImplementsTag. This meant that while the tag was recognized, it wasn't being converted into a synthetic heritage clause that TypeScript tooling could understand.

Solution

Added a case for ast.KindJSDocImplementsTag in the reparseTags function that:

  1. Creates synthetic heritage clauses with KindImplementsKeyword token
  2. Handles both class declarations and class expressions
  3. Preserves type arguments from the JSDoc tag's className
  4. Maintains existing heritage clauses when adding new implements clauses
  5. Sets appropriate flags for reparsed nodes

Examples

Before this change, JSDoc @implements tags were parsed but ignored:

/**
 * @implements {Foo}
 * @implements {Bar<string>}
 */
class MyClass extends BaseClass {
    // No synthetic heritage clauses created
}

After this change, the reparser creates proper heritage clauses:

/**
 * @implements {Foo}
 * @implements {Bar<string>}
 */
class MyClass extends BaseClass implements Foo, Bar<string> {
    // Synthetic heritage clauses enable proper type checking
}

Testing

  • ✅ Single @implements {Foo} creates heritage clause with implements keyword
  • ✅ Multiple @implements tags create multiple heritage clauses
  • ✅ Generic types like @implements {Bar<T>} handled correctly
  • ✅ Works alongside existing extends clauses
  • ✅ Supports both class declarations and class expressions
  • ✅ All existing parser tests pass
  • ✅ Build succeeds

Fixes #1103.


💡 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.

…ge clauses

Co-authored-by: sandersn <293473+sandersn@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Support jsdoc @implements tag Add support for JSDoc @implements tag in reparser Jun 9, 2025
@Copilot Copilot AI requested a review from sandersn June 9, 2025 14:02
Copilot finished work on behalf of sandersn June 9, 2025 14:03
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.

Support jsdoc @implements tag
2 participants