feat(metadata): support advanced generics using recursion#763
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview Adds Reviewed by Cursor Bugbot for commit 560f5bc. Bugbot is set up for automated code reviews on this repo. Configure here. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #763 +/- ##
==========================================
+ Coverage 78.43% 82.80% +4.36%
==========================================
Files 157 171 +14
Lines 13962 14904 +942
Branches 1152 1305 +153
==========================================
+ Hits 10951 12341 +1390
+ Misses 3006 2555 -451
- Partials 5 8 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Enforce exact TS operator precedence: Arrow functions (=>) before Unions (|) and Intersections (&). - Implement stripOuterParentheses to unwrap redundant outer groups and prevent parser depth-blindness. - Fix array loss: safely preserve [] notation for both base types and generics. - Correctly handle higher-order functions by re-joining subsequent arrow operator segments.
…is stripping, and implement function signature parsing
|
Made a little optimization |
c3ff2d3 to
560f5bc
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 560f5bc. Configure here.
| start = i + (isArrow ? 2 : 1); | ||
| if (isArrow) { | ||
| return 1; | ||
| } // skip the '>' |
There was a problem hiding this comment.
Dead code: arrow branch in splitByOuterSeparator never reached
Low Severity
The isArrow / separator === '=>' branch in splitByOuterSeparator is dead code. All call sites pass single-character separators: ',', ':', '|', or '&'. The '=>' case in parseType uses direct index-based slicing via op.index instead. This adds unnecessary branching logic and an extra return 1 path that are never exercised, making the function harder to understand.
Reviewed by Cursor Bugbot for commit 560f5bc. Configure here.


Description
This PR uses the Recursive approach instead of using Regex that just covered the basic generic and can't handle:
Transformer<T, Awaitable<U>>(str: MyType) => Promise<T>string & number | booleanThe new implementation uses a top-down Recursive approach, breaking down types layer by layer starting from the weakest operators to the strongest.
Validation
transformers.test.mjsnode --run testand verified that all test cases (old and new) passed successfully.Related Issues
This PR acts as an extension to #666. While #666 solved the basic mapping, this implementation introduces a recursive parser to handle more complex nested types.
Check List
node --run testand all tests passed.node --run format&node --run lint.