feat(metadata): support advanced generics using recursion#763
feat(metadata): support advanced generics using recursion#763moshams272 wants to merge 3 commits intonodejs:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview The generic-regex constant ( Reviewed by Cursor Bugbot for commit c69122a. 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%
=======================================
Files 157 157
Lines 13962 14000 +38
Branches 1152 1164 +12
=======================================
+ Hits 10951 10981 +30
- 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 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bb6c438. Configure here.
| // Kick off the recursive parser on the cleaned input | ||
| const markdownLinks = parseAdvancedType(typeInput, transformType); |
There was a problem hiding this comment.
| // Kick off the recursive parser on the cleaned input | |
| const markdownLinks = parseAdvancedType(typeInput, transformType); | |
| const markdownLinks = parseType(typeInput); |
Let's call this parseType, and, since it's getting very complex, let's put it in it's own file.
| const input = | ||
| '(str: MyType) => Promise<Map<string, number & string>, Map<string | number>>'; | ||
| const expected = | ||
| '(str: MyType) => [`<Promise>`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`<Map>`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[`<string>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type), [`<number>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type) & [`<string>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type)>, [`<Map>`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[`<string>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type) | [`<number>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type)>>'; |
There was a problem hiding this comment.
MyType should be handled, no?

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.