Skip to content

feat(meta): support types seperated by &#727

Open
sujalgoel wants to merge 2 commits intonodejs:mainfrom
sujalgoel:fix/intersection-type-support
Open

feat(meta): support types seperated by &#727
sujalgoel wants to merge 2 commits intonodejs:mainfrom
sujalgoel:fix/intersection-type-support

Conversation

@sujalgoel
Copy link
Copy Markdown

Summary

splitByOuterUnion only handled |, so intersection types like {A&B} came through as one unresolvable blob. No links, no splits. Found this while working on webpack-doc-kit, where TypeDoc outputs {A&B} for intersection types.

Renamed to splitByOuterSeparator, added & splitting at depth 0, and changed the return value to { pieces, separator } so the join uses the right separator instead of always hardcoding |.

Changes

  • splitByOuterUnion -> splitByOuterSeparator
  • splits on | and & at depth 0
  • returns { pieces, separator }
  • transformTypeToReferenceLink now joins with the returned separator
  • two new tests added

Test plan

  • 378/378 existing tests pass
  • {string&boolean} links both parts with &
  • {Map<string, number>&Array<string>} links both generic parts with &

splitByOuterUnion only split on |, so intersection types like {A&B}
were treated as a single unresolvable piece instead of having each
component individually linked.

Rename the function to splitByOuterSeparator and extend it to also
split on & at depth 0. It now returns both the pieces and the separator
string (' | ' or ' & ') so the join at the call site uses the correct
separator rather than a hardcoded ' | '.
@sujalgoel sujalgoel requested a review from a team as a code owner March 29, 2026 23:20
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 29, 2026

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

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Mar 29, 2026 11:49pm

Request Review

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.

🙌 Neat PR!

const pieces = [];
let current = '';
let depth = 0;
let separator = ' | ';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
let separator = ' | ';
let separator;

} else if ((char === '|' || char === '&') && depth === 0) {
pieces.push(current);
current = '';
separator = char === '&' ? ' & ' : ' | ';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
separator = char === '&' ? ' & ' : ' | ';
separator ??= ` ${char} `;

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.40%. Comparing base (27de0e7) to head (e8b5058).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #727      +/-   ##
==========================================
+ Coverage   76.37%   76.40%   +0.03%     
==========================================
  Files         155      155              
  Lines       13766    13785      +19     
  Branches     1093     1096       +3     
==========================================
+ Hits        10514    10533      +19     
  Misses       3247     3247              
  Partials        5        5              

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

@avivkeller avivkeller changed the title metadata: support intersection types in transformTypeToReferenceLink feat(meta): support types seperated by & Mar 29, 2026
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