Skip to content

fix(metadata): support TS prefix operators in typeParser#883

Open
moshams272 wants to merge 1 commit into
nodejs:mainfrom
moshams272:fix/type-parser-prefixes
Open

fix(metadata): support TS prefix operators in typeParser#883
moshams272 wants to merge 1 commit into
nodejs:mainfrom
moshams272:fix/type-parser-prefixes

Conversation

@moshams272

Copy link
Copy Markdown
Contributor

Description

Currently, the typeParser in src/generators/metadata/utils/typeParser.mjs fails to resolve types that have prefix operators such as typeof, keyof, readonly, and unique.

Because the parser treats the prefix and the target type as a single continuous string (e.g., "typeof Compiler"), it fails to find a match in the type-map, resulting in dead links and plain text rendering in the documentation.

This PR introduces a check for these common prefix operators before falling back to array or generic processing. It strips the prefix, formats it as plain text, and recursively passes the remaining target type to resolveOr so it can be correctly matched and linked.

Validation

Tested it on webpack-doc-kit:

Before:
image

After:
image

Related Issues

No related issues.

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run node --run test and all tests passed.
  • I have check code formatting with node --run format & node --run lint.
  • I've covered new added functionality with unit tests if necessary.

@moshams272 moshams272 requested a review from a team as a code owner July 5, 2026 08:29
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Jul 5, 2026 8:30am

Request Review

@cursor

cursor Bot commented Jul 5, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Small, localized change to metadata type-string formatting with unit tests; no auth, runtime, or data-path impact.

Overview
parseType now recognizes TypeScript prefix operators typeof, keyof, readonly, and unique before array and generic handling. It keeps the prefix as plain text and recursively resolves the remainder so names like Compiler in typeof Compiler can match the type map and render as links instead of one unlinked blob.

Tests cover linked typeof types and confirm identifiers such as typeofSomething are not treated as prefixed types.

Reviewed by Cursor Bugbot for commit b56667c. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.02%. Comparing base (9c5f11f) to head (b56667c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #883      +/-   ##
==========================================
+ Coverage   85.00%   85.02%   +0.02%     
==========================================
  Files         179      179              
  Lines       16453    16479      +26     
  Branches     1491     1497       +6     
==========================================
+ Hits        13986    14012      +26     
  Misses       2457     2457              
  Partials       10       10              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant