feat(metadata): support advanced generics using recursion#763
feat(metadata): support advanced generics using recursion#763moshams272 wants to merge 4 commits intonodejs:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview Removes the old Reviewed by Cursor Bugbot for commit 00d8c39. 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% 78.43% -0.01%
==========================================
Files 157 158 +1
Lines 13962 13998 +36
Branches 1152 1165 +13
==========================================
+ Hits 10951 10979 +28
- Misses 3006 3011 +5
- Partials 5 8 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 00d8c39. Configure here.
| parseType(returnType, transformType) || `\`<${returnType}>\``; | ||
| return `${params} => ${parsedReturn}`; | ||
| } | ||
| } |
There was a problem hiding this comment.
Function arrow operator precedence is incorrect in parser
High Severity
The => (function arrow) handling is checked after | and &, but in TypeScript type syntax => is the weakest-binding operator — its return type extends to the right consuming unions and intersections. For input like (err: Error) => string | null, the parser first finds | at the outer level (depth 0), splits into (err: Error) => string and null, and incorrectly produces a union instead of a function returning string | null. The => check needs to come before the | and & checks so the return type is kept whole and recursively parsed.
Reviewed by Cursor Bugbot for commit 00d8c39. 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.