feat(js_interop_gen): support TS Compiler API and resolve all type-system errors - #560
feat(js_interop_gen): support TS Compiler API and resolve all type-system errors#560kevmoo wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances the js_interop_gen tool by improving member conflict resolution, type hierarchy resolution, and generic type parameter validation during code generation. It also adds escaping for unintended HTML tags in doc comments to prevent Dart analyzer warnings. The review feedback highlights several critical and high-severity issues, including incorrect string interpolation of TypeReference objects inside Code(...) blocks, potential cache collisions in _memberHierarchyCache from using non-unique names, and unsafe in-place mutation of shared AST type instances. Additionally, the reviewer recommends respecting member renaming when resolving conflicts and removing leftover debug print statements.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
026f0ef to
ca900d4
Compare
|
|
||
| static const AnonymousUnion_7177595 polygon = AnonymousUnion_7177595._( | ||
| 'polygon', | ||
| static final AnonymousUnion_7177595 polygon = AnonymousUnion_7177595._( |
There was a problem hiding this comment.
I don't LIKE this change. I need to dig in to understand what changed
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the JS interop generator to improve type hierarchy resolution, support merged declarations, and update enum representation types to use JS types instead of primitive Dart types. It also adds HTML tag escaping in documentation formatting to prevent analyzer warnings. The review feedback suggests avoiding in-place mutation of shared AST type instances in sub_type.dart, expanding the allowed HTML tags list in formatting.dart, and implementing cycle guards in getMemberHierarchy and findMemberInHierarchy to prevent infinite recursion on circular type hierarchies.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…stem errors Migrate js_interop_gen parser infrastructure to use the TypeScript Compiler API bindings. - Add generated TypeScript API bindings in lib/src/js/generated/typescript_api.dart and binding update script. - Refactor AST nodes, type representation, and parser logic to interface with the TypeScript Compiler API. - Fix sub-type hierarchy, type mapping, and union casting resolution. - Restore SDK-internal formatting for golden test expected files and update generator goldens.
3715854 to
5434de9
Compare
- Use cloneType in getLowestCommonAncestorOfTypes to prevent in-place nullability mutation. - Add img, hr, details, summary to allowed HTML tags in doc comment formatting. - Add visited set cycle guards to getMemberHierarchy and findMemberInHierarchy. - Add unit tests in generate_docs_test and type_map_test.
This PR is Phase 2 of our JS Interop generator migration, and is perfectly stacked on top of the Node.js migration PR (
more_dts).It migrates the massive, complex TypeScript Compiler API to the dogfooded generator, producing a ~10,000-line
typescript_api.dartfile that compiles and analyzes with perfect 100% cleanliness—zero errors, zero warnings, and zero infos!🛠️ Summary of Breakthroughs & Fixes
createTypeMapto correctly discover underlying custom interface bounds.deduceTypeto check thetypeMapfirst, ensuring type parameters like<JSAny>are never lost during LCA resolution.JSObjectorJSAnybased on whether the representation type is a subtype ofJSObject.JSNumber/JSStringand explicitly implement them to resolve bounds mismatches.formatDocsthat automatically wraps HTML-like tags (such as<reference ...>or<T>) in backticks, styling them as inline code and completely satisfying the analyzer without over-escaping tags already inside code blocks.ClosureTypeconstructor.type_map_test.dartwith 100% green coverage.