feat(meta): support types seperated by ˗
Open
sujalgoel wants to merge 2 commits intonodejs:mainfrom
Open
Conversation
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 ' | '.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
avivkeller
approved these changes
Mar 29, 2026
| const pieces = []; | ||
| let current = ''; | ||
| let depth = 0; | ||
| let separator = ' | '; |
Member
There was a problem hiding this comment.
Suggested change
| let separator = ' | '; | |
| let separator; |
| } else if ((char === '|' || char === '&') && depth === 0) { | ||
| pieces.push(current); | ||
| current = ''; | ||
| separator = char === '&' ? ' & ' : ' | '; |
Member
There was a problem hiding this comment.
Suggested change
| separator = char === '&' ? ' & ' : ' | '; | |
| separator ??= ` ${char} `; |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
&
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
splitByOuterUniononly 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|and&at depth 0{ pieces, separator }transformTypeToReferenceLinknow joins with the returned separatorTest plan
{string&boolean}links both parts with&{Map<string, number>&Array<string>}links both generic parts with&