Unify Flow and TypeScript event and command parsing into shared modules#56052
Open
christophpurrer wants to merge 2 commits intofacebook:mainfrom
Open
Unify Flow and TypeScript event and command parsing into shared modules#56052christophpurrer wants to merge 2 commits intofacebook:mainfrom
christophpurrer wants to merge 2 commits intofacebook:mainfrom
Conversation
…tifier helper (facebook#56049) Summary: Reduce duplication and inconsistency across codegen generators by centralizing reserved primitive type mappings into a single `ReservedPrimitiveTypes.js` registry, making future type support and fixes a single-source change and lowering bug risk. Additionally, standardize identifier capitalization via a shared `toSafeIdentifier` helper in `Utils.js` to prevent divergent string handling across C++/Java helpers. Also removes dead TODO comments and obsolete commented-out code from `RNCodegen.js`, `GenerateModuleH.js`, and parser files. Changelog: [Internal] Differential Revision: D95711348
Summary: Extract duplicated event and command type resolution logic from Flow and TypeScript parsers into shared modules (`events-commons.js` and `commands-commons.js`), eliminating ~300 lines of near-identical code. Both parsers now delegate to the same type resolution functions, which use the parser interface (`extractTypeFromTypeAnnotation` and `convertKeywordToTypeAnnotation`) to normalize language-specific AST differences. Also fixes `extractTypeFromTypeAnnotation` in the Flow parser to correctly handle `QualifiedTypeIdentifier` (e.g. `CodegenTypes.Int32`) and adds missing `TSUnionType` mapping in the TypeScript parser. Changelog: [Internal] Differential Revision: D95728706
|
@christophpurrer has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95728706. |
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:
Extract duplicated event and command type resolution logic from Flow and TypeScript parsers into shared modules (
events-commons.jsandcommands-commons.js), eliminating ~300 lines of near-identical code.Both parsers now delegate to the same type resolution functions, which use the parser interface (
extractTypeFromTypeAnnotationandconvertKeywordToTypeAnnotation) to normalize language-specific AST differences.Also fixes
extractTypeFromTypeAnnotationin the Flow parser to correctly handleQualifiedTypeIdentifier(e.g.CodegenTypes.Int32) and adds missingTSUnionTypemapping in the TypeScript parser.Changelog: [Internal]
Differential Revision: D95728706