Skip to content

fix(queries): allow complex types in type linking regex#814

Open
moshams272 wants to merge 2 commits into
nodejs:mainfrom
moshams272:fix/allow-generics-in-queries
Open

fix(queries): allow complex types in type linking regex#814
moshams272 wants to merge 2 commits into
nodejs:mainfrom
moshams272:fix/allow-generics-in-queries

Conversation

@moshams272
Copy link
Copy Markdown
Collaborator

Description

Currently, doc-kit fails to parse and link complex JSDoc types that contain generics, unions and arrow functions.

This happens because the regex in src/utils/queries/index.mjs uses [^<({})>]+, which excludes <, >, (, and ). When the parser encounters these characters, it ignores the entire type block, leaving it unlinked and sometimes causing Markdown parsers (Remark) to see them as HTML tags.

This PR updates the regex exclusion list to [^{}]+.

Validation

Before:
Screenshot from 2026-05-30 15-13-38

After:
Screenshot from 2026-05-30 15-19-35

Related Issues

No related one.

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 May 30, 2026 12:29
@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

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

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview May 30, 2026 2:13pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 30, 2026

PR Summary

Low Risk
Small, localized change to documentation parsing regexes with no auth, data, or runtime API impact; main risk is edge-case over-matching on malformed {/} type syntax.

Overview
Fixes API doc type linking for JSDoc-style {Type} / <Type> references that include generics, unions, and arrow functions by relaxing what characters can appear inside the type span.

The normalizeTypes and linksWithTypes patterns in src/utils/queries/index.mjs no longer treat (, ), <, and > as hard stops; they only exclude { and } so nested punctuation can be matched and turned into links instead of being skipped or misread as HTML.

Release 1.3.7 is bumped in package.json and package-lock.json.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.86%. Comparing base (bf76f97) to head (503aefe).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #814   +/-   ##
=======================================
  Coverage   82.86%   82.86%           
=======================================
  Files         171      171           
  Lines       14961    14961           
  Branches     1313     1313           
=======================================
  Hits        12398    12398           
  Misses       2554     2554           
  Partials        9        9           

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run npm version patch?

Copy link
Copy Markdown
Member

@AugustinMauroy AugustinMauroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT ! is there are test for that ?

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.

3 participants