Skip to content

Unify Flow and TypeScript event and command parsing into shared modules#56052

Open
christophpurrer wants to merge 2 commits intofacebook:mainfrom
christophpurrer:export-D95728706
Open

Unify Flow and TypeScript event and command parsing into shared modules#56052
christophpurrer wants to merge 2 commits intofacebook:mainfrom
christophpurrer:export-D95728706

Conversation

@christophpurrer
Copy link
Contributor

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

…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
@meta-codesync
Copy link

meta-codesync bot commented Mar 11, 2026

@christophpurrer has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95728706.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants