Commit Graph

835 Commits

Author SHA1 Message Date
Leonardo Rota-Rossi 8ca085c09c Create a function emitDoubleProp (#37515)
Summary:
> Create a function emitDoubleProp(name: string, optional: boolean) in parser-primitives.js. Factor out the code from [Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/events.js#L61-L67) and [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/events.js#L71-L77) into that function. Use that function in the original call site.

bypass-github-export-checks

## Changelog:

[INTERNAL][ADDED] - emitDoubleProp in parser primitves

Pull Request resolved: https://github.com/facebook/react-native/pull/37515

Test Plan: yarn jest packages/react-native-codegen

Reviewed By: cortinico

Differential Revision: D46149450

Pulled By: cipolleschi

fbshipit-source-id: 78381214a79c33d975dff490599d510e8001254e
2023-05-25 02:59:23 -07:00
Luiz Ozorio 706239814e Create emitStringProp function (#37527)
Summary:
> Create a function emitStringProp(name: string, optional: boolean) in parser-primitives.js. Factor out the code from [Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/events.js#L45-L51) and [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/events.js#L57-L61) into that function. Use that function in the original call site.

bypass-github-export-checks

## Changelog:

[INTERNAL][ADDED] - emitStringProp in parser-primitves

Pull Request resolved: https://github.com/facebook/react-native/pull/37527

Test Plan: `yarn jest packages/react-native-codegen`

Reviewed By: cortinico

Differential Revision: D46144200

Pulled By: cipolleschi

fbshipit-source-id: 076b530905ba7c28cfb2151e29e589026010c3c3
2023-05-25 02:59:23 -07:00
Frank Calise 66f4a9168b Codegen 123: add parser-primitive function for emitBoolProp (#37488)
Summary:
Part of https://github.com/facebook/react-native/issues/34872, Improving Codegen

Reduces code duplication by creating a helper function `emitBoolProp(name: string, optional: boolean)` in `parser-primitives.js`. Refactors the code from [Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/events.js#L37-L43) and [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/events.js#L47-L53) to utilize the new function.

bypass-github-export-checks

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[INTERNAL] [CHANGED] - Extract contents of the case `BooleanTypeAnnotation` and `TSBooleanKeyword` into a single `emitBoolProp` function

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/37488

Test Plan:
Run `yarn jest react-native-codegen`

<img width="392" alt="image" src="https://github.com/facebook/react-native/assets/374022/79dae56d-e12d-4be2-9426-50a72e893dfe">

Reviewed By: dmytrorykun

Differential Revision: D46073996

Pulled By: cipolleschi

fbshipit-source-id: 4af67e7e9c3ee1712159c7a647790cb431cfb17a
2023-05-25 02:59:23 -07:00
shubham0142 af8b03d805 refactor(codegen): add throwIfTypeAliasIsNotInterface in error-utils (#37530)
Summary:
part of codegen issue https://github.com/facebook/react-native/issues/34872

> Extract the code that checks whether typeAlias.type is an InterfaceDeclaration ([Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/index.js#L76-L80), [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/index.js#L76-L80)) into a throwIfTypeAliasIsNotInteface error. Create this new function in the error-utils.js file.

bypass-github-export-checks

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal][Added]: Add throwIfTypeAliasIsNotInterface in error-utils

Pull Request resolved: https://github.com/facebook/react-native/pull/37530

Test Plan: yarn test react-native-codegen

Reviewed By: dmytrorykun

Differential Revision: D46143299

Pulled By: cipolleschi

fbshipit-source-id: 3eb0f5d687d3a4f64822540f4f572d872b81828f
2023-05-25 02:59:23 -07:00
Pranav Yadav e240879057 Refactor: Extract findComponentConfig(...) to parsers-commons.js (#37547)
Summary:
This PR extracts the `findComponentConfig(...)` Flow and TS from the `index.js`'s files to the `parser-commons.js` file.

bypass-github-export-checks

## Changelog:

[INTERNAL][CHANGED] - Refactor: Extract `findComponentConfig(...)` from Flow & TS to `parsers-commons.js`

Pull Request resolved: https://github.com/facebook/react-native/pull/37547

Test Plan: - `yarn flow && yarn test packages/react-native-codegen`  → should be green.

Reviewed By: cortinico

Differential Revision: D46143481

Pulled By: cipolleschi

fbshipit-source-id: f9a456b1d58312422b17463ed2b60ee5fda16462
2023-05-25 02:59:23 -07:00
shubham0142 cf8184d5ab refactor(codegen): add undefinedLiteralTypeAnnotation prop in parsers (#37450)
Summary:
part of codegen issue https://github.com/facebook/react-native/issues/34872

> Add an undefinedLiteralTypeAnnotation: string property into the Parser object and implement it in the FlowParser (returning VoidLiteralTypeAnnotation) and in the TypeScriptPArser(returning TSUndefinedKeyword). Replace them in and [parsers/typescript/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L158).

bypass-github-export-checks

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal][Added]: Add undefinedLiteralTypeAnnotation property in parsers

Pull Request resolved: https://github.com/facebook/react-native/pull/37450

Test Plan: yarn test

Reviewed By: dmytrorykun

Differential Revision: D45904567

Pulled By: cipolleschi

fbshipit-source-id: edd26198e4c8b191a473d5b0ff96a6dc1fec8576
2023-05-25 02:59:23 -07:00
Siddarth Kumar fc927d1fb7 Add getProps to Parsers and fix up usages (#37504)
Summary:
[Codegen 87] This PR introduces `getProps` to the Parser class and implements this function in Typescript and Flow Parsers.

We also get rid of the following files from :
- `packages/react-native-codegen/src/parsers/typescript/components/props.js`
-  `packages/react-native-codegen/src/parsers/flow/components/props.js`

as requested on https://github.com/facebook/react-native/issues/34872

bypass-github-export-checks

## Changelog:

[Internal] [Changed] - Add `getProps ` to Parsers and update usages.

Pull Request resolved: https://github.com/facebook/react-native/pull/37504

Test Plan: Run yarn jest react-native-codegen and ensure CI is green

Reviewed By: cortinico

Differential Revision: D46074152

Pulled By: cipolleschi

fbshipit-source-id: aa6a1a556c9b4a4a6209221f70c8add46ed2d08b
2023-05-25 02:59:23 -07:00
Riccardo Cipolleschi 8dcaa4cc3b Remove duplicated code that resulted after a merge conflict. (#37477)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37477

When creating a stack of several codegen fixes, a conflit generated some duplicated code we moved to the parsers from the utils.

This change removes that duplicated cone.

## Changelog:
[Genearal][Fixed] - Remove duplicated code.

Reviewed By: cortinico

Differential Revision: D45979013

fbshipit-source-id: 78cb89df81305221258e283ba5924135d498e800
2023-05-22 03:35:46 -07:00
Riccardo Cipolleschi 718582d3bb Fixing Typo in Codegen's Interface Declaration (#37475)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37475

We recently landed a change with a typo in the interface declaration. We just fixed the typo

## Changelog:
[General][Fixed] - Fixed a typo in the interface declaration

Reviewed By: robhogan

Differential Revision: D45978419

fbshipit-source-id: f44dbcd5c1706b9582b997a5eb6c0a82d0e422cc
2023-05-22 03:35:46 -07:00
Lorenzo Sciandra f10dd3f666 bump @babel/* packages (#35787)
Summary:
X-link: https://github.com/facebook/metro/pull/987

While working on https://github.com/facebook/react-native/pull/35786 I noticed some inconsistencies in the versioning for Babel and Flow across the monorepo. So in this PR I wanted to address that so that for 0.72 we'll have the codebase in a more consistent shape.

Happy to split in multiple PRs if needed.

## Changelog
[GENERAL] [CHANGED] - Bump Babel packages to ^7.20.0 (or closest latest release), bump flow parser to 0.206.0 in a few places that were left out from latest bump

Pull Request resolved: https://github.com/facebook/react-native/pull/35787

Test Plan: CI is green.

Reviewed By: cipolleschi

Differential Revision: D42384881

Pulled By: hoxyq

fbshipit-source-id: 21fd43391d12722cf707c3cdbbb36f49c036359d
2023-05-18 14:05:38 -07:00
Christoph Purrer f7dcc65a3f Remove unused jsInvoker from Cxx TM enums (#37454)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37454

Raised here: https://github.com/reactwg/react-native-releases/discussions/54#discussioncomment-5914928

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D45918922

fbshipit-source-id: 931d2017c37e7327ba472c36e3ac0b29b74d093d
2023-05-17 08:33:36 -07:00
Antoine Doubovetzky f05252ae4e refactor(codegen): extract throwIfArgumentPropsAreNull function in error-utils (#37252)
Summary:
This PR contains task 117 from https://github.com/facebook/react-native/issues/34872:
> [Codegen 117] Extract the code that throws if argumentProps are null in a throwIfArgumentPropsAreNull function in the error-utils.js file. Use it in the [flow/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/components/events.js#L240-L242) and in the [typescript/components/event.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L230-L231) files

bypass-github-export-checks

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal] [Changed] - Extract throwIfArgumentPropsAreNull function in error-utils

Pull Request resolved: https://github.com/facebook/react-native/pull/37252

Test Plan: I tested using Jest and Flow commands.

Reviewed By: dmytrorykun

Differential Revision: D45865671

Pulled By: cipolleschi

fbshipit-source-id: 6711dbed0a5ccd56075e0d13ffa13b222979b8c7
2023-05-17 03:45:34 -07:00
Kyaw Thura b5c01ee945 Add a nullLiteralTypeAnnotation: string property into the Parser object (#37387)
Summary:
Part of https://github.com/facebook/react-native/issues/34872
> [Codegen 110] Add a nullLiteralTypeAnnotation: string property into the Parser object and implement it in the FlowParser (returning
NullLiteralTypeAnnotation) and in the TypeScriptParser(returning TSNullKeyword). Replace them in the [parsers/flow/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/components/events.js#L137-L138) and [parsers/typescript/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L157).

bypass-github-export-checks

## Changelog:

[Internal][Added]: Add nullLiteralTypeAnnotation property in Parser object

Pull Request resolved: https://github.com/facebook/react-native/pull/37387

Test Plan: `yarn test react-native-codegen`

Reviewed By: dmytrorykun

Differential Revision: D45779075

Pulled By: cipolleschi

fbshipit-source-id: 4ebcf8e1039d7e9188fdfe811fae1720fcba1994
2023-05-17 03:45:34 -07:00
shubham0142 9301c8fea5 codegen 107: add interfaceDeclaration prop in parsers (#37361)
Summary:
part of codegen issue https://github.com/facebook/react-native/issues/34872

> Add a interfaceDeclaration: string property to the Parser class. Implement it in the Flow parser so that it returns InterfaceDeclaration and in the TypeScriptParser so that it returns TSInterfaceDeclaration. Replace the case in the switch  in the [parsers/typescript/utils.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/utils.js#L69) with this prop.

bypass-github-export-checks

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal][Added]: Add interfaceDeclaration property in parsers

Pull Request resolved: https://github.com/facebook/react-native/pull/37361

Test Plan: yarn test

Differential Revision: D45769316

Pulled By: cipolleschi

fbshipit-source-id: a7f3c6339984e643e3e35fb5b920442aea027b78
2023-05-17 03:45:34 -07:00
tarunrajput 91c60cb365 Codegen 106: add enumDeclaration property in parser class (#37355)
Summary:
Part of Codegen Issue: https://github.com/facebook/react-native/issues/34872

> Add a enumDeclaration: string property to the Parser class. Implement it in the Flow parser so that it returns EnumDeclaration and in the TypeScriptParser so that it returns TSEnumDeclaration. Replace the case in the switch  in the [parsers/flow/utils.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/utils.js#L66) and [parsers/typescript/utils.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/utils.js#L78) with this prop.

bypass-github-export-checks

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal][Added] - Add enumDeclaration property in parser class

Pull Request resolved: https://github.com/facebook/react-native/pull/37355

Test Plan: ```yarn test```

Reviewed By: christophpurrer

Differential Revision: D45736088

Pulled By: cipolleschi

fbshipit-source-id: 706a9f1fff52563e12dd6fc54cb0e89c396bba7c
2023-05-17 03:45:34 -07:00
tarunrajput 0de476803c Codegen 105: add typeAlias prop in parsers (#37334)
Summary:
Part of Codegen Issue: https://github.com/facebook/react-native/issues/34872
> Add a typeAlias: string property to the Parser class. Implement it in the Flow parser so that it returns TypeAlias and in
> the TypeScriptParser so that it returns TSTypeAliasDeclaration. Replace the case in the switch  in the [parsers/flow/utils.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/utils.js#L57) and [parsers/typescript/utils.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/utils.js#L60) with this prop.

bypass-github-export-checks

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal][Added]: Add typeAlias property in parsers

Pull Request resolved: https://github.com/facebook/react-native/pull/37334

Test Plan: ```yarn test```

Reviewed By: dmytrorykun

Differential Revision: D45691915

Pulled By: cipolleschi

fbshipit-source-id: efe5c87afc3193f6a35325190a67f98d64426ab3
2023-05-17 03:45:34 -07:00
Siddarth Kumar e09d5856f4 Add getResolvedTypeAnnotation to Parsers (#37373)
Summary:
[Codegen 104] This PR introduces `getResolvedTypeAnnotation` to the Parser class and implements this function in Typescript and Flow Parsers.

We also get rid of usages `resolveTypeAnnotation` from :
- `packages/react-native-codegen/src/parsers/typescript/utils.js`
-  `packages/react-native-codegen/src/parsers/flow/utils.js`

and replace it with `parsers.getResolvedTypeAnnotation` as requested on https://github.com/facebook/react-native/issues/34872

bypass-github-export-checks

## Changelog:

[Internal] [Changed] - Add `getResolvedTypeAnnotation ` to Parsers and update usages.

Pull Request resolved: https://github.com/facebook/react-native/pull/37373

Test Plan: Run yarn jest react-native-codegen and ensure CI is green

Reviewed By: dmytrorykun

Differential Revision: D45865651

Pulled By: cipolleschi

fbshipit-source-id: fdce6e5059306ebe67121aa1b212e67de864bf84
2023-05-17 03:45:34 -07:00
Riccardo Cipolleschi b6b09a7e72 Add support for distributed registration of Fabric Components with Dynamic Libraries (#37274)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37274

With dynamic frameworks, we can't use floating C functions.

The way in which dynamic frameworks work is that they need to be self contained. They are built in isolation so that other frameworks can be linked against them to solve their dependencies.

Currently, when working with 3rd party libraries, we are Codegenerating a RCTThirdPartyComponentProvider which tries to invoke floating C functions that are defined in other modules. React-RCTFabric has no visibility on those modules, therefore it fails building.

The implemented solution exclude the generation of those symbols and leverage a the Objective-C runtime to automatically register libraries when they are loaded.

**This mechanism is applied ONLY when the flag RCT_DYNAMIC_FRAMEWORKS is turned on.** There will be no impact on internal meta apps, nor on any apps that are not using Dynamic Frameworks.

This change requires a small migration in all the Fabric components libraries that wants to support dynamic frameworks. They have to implement a
```
+ (void)load
{
  [super load];
}
```
method in their ComponentView.

Not to slow down the adoption of the new architecture, waiting for a migration in the ecosystem, the next diff introduce a secondary, declarative loading mechanism for Fabric Components, which follows the same approach used by TurboModules.

## Changelog:
[iOS][Changed] - Add support for distributed registration of  Fabric Components with Dynamic Libraries.

Notes that this change is NOT breaking as dynamic frameworks were not working before in the New Architecture. Static Libraries and Static Frameworks continue working as usual.

Reviewed By: dmytrorykun

Differential Revision: D45605441

fbshipit-source-id: e609fbf6f92fddfbaa676227fde60962d6b0faa4
2023-05-15 08:14:59 -07:00
Ken Tominaga 0212179293 Use buildPropSchema from parser-commons (#37043)
Summary:
> The `buildPropSchema` function in `parsers/typescript/components/props.js` and `parsers/flow/components/props.js` is the same. move it to `parser-commons` and use it in the original files.

part of https://github.com/facebook/react-native/issues/34872

- [x] Make the getTypeAnnotation signature from the Flow package to be equal to the typescript one. Specifically, the Typescript one needs an additional parameter withNullDefault that we can safely ignore in the implementation.
- [x] buildPropSchema signature can be updated to accept those two functions in input as callbacks. Then, the getProps function can feed the right functions based on the language to the shared build prop schema.

ref: https://github.com/facebook/react-native/issues/34872#issuecomment-1517519254

bypass-github-export-checks

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal] [Changed] - Use `buildPropSchema` from parser-commons

Pull Request resolved: https://github.com/facebook/react-native/pull/37043

Test Plan: - [ ] `yarn jest react-native-codegen` pass

Reviewed By: rshest

Differential Revision: D45209982

Pulled By: cipolleschi

fbshipit-source-id: c241bc0542ba662c965d70d1dc283f48541e14ea
2023-05-11 05:36:45 -07:00
shubham0142 ec66f2eeb9 Codegen 113: add isOptionalProperty in parser (#37134)
Summary:
part of codegen issue https://github.com/facebook/react-native/issues/34872
Add a function isOptionalProperty(property) in the Parser object and implement it in FlowParser and TypeScriptParser, using the implementation you can find in the [parsers/flow/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/components/events.js#L172-L173) and [parsers/typescript/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L196). Use the parsers in the buildPropertiesForEvent.

bypass-github-export-checks

## Changelog:
[Internal][Changed]: add isOptionalProperty in parser and use it in parser events.
<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/37134

Test Plan: `yarn test react-native-codegen`

Reviewed By: christophpurrer

Differential Revision: D45390880

Pulled By: cipolleschi

fbshipit-source-id: bb2575b8602c6a15be0a87817ca1961ae834324e
2023-05-09 05:35:45 -07:00
Siddarth Kumar d46f92cdad move getEventArgument function into parsers-commons.js (#37133)
Summary:
[Codegen 116] This PR attempts to extract the logic of `getEventArgument` function from the following locations :
- `parsers/flow/components/events.js`
- `parsers/typescript/components/events.js`
since they are the same and move the function to `parsers/parsers-commons.js` as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[Internal] [Changed] - Move `getEventArgument` to parser-commons and update usages.

Pull Request resolved: https://github.com/facebook/react-native/pull/37133

Test Plan: Run `yarn jest react-native-codegen` and ensure CI is green

Reviewed By: christophpurrer

Differential Revision: D45569128

Pulled By: cipolleschi

fbshipit-source-id: 63a7619e5b4fca0157c62a359ac51831f4f15945
2023-05-04 11:16:37 -07:00
Zihan Chen (MSFT) 4fd8f405be Recognize dictionary type in codegen (#37206)
Summary:
Previously we allow `{[key:string]:Something}` in codegen, `Something` is type-checked but thrown away, generating a `GenericObjectTypeAnnotation`.
In this change, `Something` is added to `GenericObjectTypeAnnotation` as an optional field.
For downstream code such as C++ codegen, this change is **backward compatible**. It allows C++ codegen to produce a more precious type optionally.

## Changelog:

[General] [Added] - Recognize dictionary type in codegen

Pull Request resolved: https://github.com/facebook/react-native/pull/37206

Test Plan:
```
yarn jest react-native-codegen
yarn jest react-native-codegen-typescript-test
```

Reviewed By: cipolleschi

Differential Revision: D45563340

Pulled By: dmytrorykun

fbshipit-source-id: 9a9ce36df6ded6d42d35c3dcb6fb0eaca16c4458
2023-05-04 05:04:12 -07:00
Riccardo Cipolleschi b422375782 Add support for Arrays in generator (#37145)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37145

This diff adds the generation of Array types in events.

It supports the generation of Array of:
- Boolean
- Int32
- Float
- Double
- String
- Objects
- Array

**Note:** This is a first iteration. We could improve the generation further by leveraging the `Bridging` module within React Native.
I'll take a stab at it in a next diff.

## Changelog:
[General][Added] - Generate events with arrays

Reviewed By: cortinico

Differential Revision: D45321685

fbshipit-source-id: 34b05f5501b06714d1fabf1a51cb057af7027f00
2023-05-04 04:11:49 -07:00
Riccardo Cipolleschi 6168701887 Support Array parsing in events (#37142)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37142

This diff introduce support to parse arrays in events.

We support parsing Arrays of:
- Boolean
- Double
- Float
- Int32
- String Enums
- String
- Objects
- Arrays

## Changelog:
[General][Added] - Add generic support for Arrays in Events parsing

Reviewed By: dmytrorykun, RSNara

Differential Revision: D45268779

fbshipit-source-id: 0c6eae65eb2b41ebf7b47a4cc3e0f0e5fa20d871
2023-05-04 04:11:49 -07:00
tarunrajput 849470702f Codegen 118: add throwIfBubblingTypeisNull in error-utils and use it in events (#37191)
Summary:
part of codegen Issue https://github.com/facebook/react-native/issues/34872

> Extract the code that throws if argumentProps are null in a throwIfBubblingTypeisNull function in the error-utils.js file. Use it in the [flow/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/components/events.js#L244-L246) and in the [typescript/components/event.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L232-L233) files

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal][Changed]: Add throwIfBubblingTypeisNull in error-utils and use it in events

Pull Request resolved: https://github.com/facebook/react-native/pull/37191

Test Plan: `yarn jest react-native-codegen`

Reviewed By: cipolleschi

Differential Revision: D45478073

Pulled By: dmytrorykun

fbshipit-source-id: f70ce3f32d93170cafcea9c8b8c2ba06e760fa37
2023-05-02 09:12:10 -07:00
Pranav Yadav 14316bd635 Add missing READMEs & Update package.json in all RN packages (#37090)
Summary:
This diff adds _missing_ README files for all public RN packages.

#### Changes:
For all public RN packages:
- Add _Missing_ READMEs

Update package.json in all RN packages to add:
- Issues, Bugs urls
- Keywords and Homepage urls to respective pkgs

## Changelog:

[GENERAL][ADDED] - Add missing README files for all public RN packages.
[GENERAL][CHANGED] - Update package.json in all RN packages to add required fields.

Pull Request resolved: https://github.com/facebook/react-native/pull/37090

Test Plan: - `yarn lint && yarn flow && yarn test-ci` --> _should be green_

Reviewed By: cortinico

Differential Revision: D45390861

Pulled By: hoxyq

fbshipit-source-id: 524a92de56a7cb553573d9f54ccf40a998dfd35f
2023-04-28 04:26:20 -07:00
Pranav Yadav a58dea1e9e Update Node.js to v16 in all RN packages (#37073)
Summary:
**NOTE**: This is a **BREAKING** change.
TLDR; Enforce minimum Node.js v16 in all RN packages.

This diff **Updates Node.js to v16** across all RN packages.

#### Context:

- For RN development and new project created; bump to node 16 was in https://github.com/facebook/react-native/pull/36217
- Recently `react-native-windows` also; updated node to v16, https://github.com/microsoft/react-native-windows/pull/11500

#### Changes:

- [BREAKING] Update Node.js to v16 across all RN packages under 'packages/' dir

## Changelog:

[GENERAL][BREAKING] - Update Node.js to v16 in all RN packages

Pull Request resolved: https://github.com/facebook/react-native/pull/37073

Test Plan: - `yarn lint && yarn flow && yarn test-ci` --> _should be green_

Reviewed By: cipolleschi

Differential Revision: D45306108

Pulled By: jacdebug

fbshipit-source-id: e3ba7d0151b86a6a0a3d63fb29c2bd887e1ac1e7
2023-04-26 08:24:06 -07:00
Siddarth Kumar c937162cd5 move extendsForProp into parsers-commons (#37052)
Summary:
[Codegen 94] This PR attempts to extracts the logic of `extendsForProp` function from the following locations :
- `parsers/flow/components/extends.js`
- `parsers/typescript/components/props.js`
since they are the same and move the function to `parsers/parsers-commons.js` as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[Internal] [Changed] - Move `extendsForProp` to parser-commons and update usages.

Pull Request resolved: https://github.com/facebook/react-native/pull/37052

Test Plan: Run `yarn jest react-native-codegen` and ensure CI is green

Reviewed By: cipolleschi

Differential Revision: D45225880

Pulled By: rshest

fbshipit-source-id: 45199089746d58d9e9494b28040b34c2a0eb31fe
2023-04-26 04:25:54 -07:00
Samuel Susla fc5a7f7567 Remove use of JSI_EXPORT from codegen (#37085)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37085

changelog: [internal]

Props and event emitter does not need to use JSI_EXPORT. Therefore we can remove include of jsi.h as well.

Reviewed By: cortinico, rshest

Differential Revision: D45274824

fbshipit-source-id: dd756258767f787e49d86dc31e18ce581f444362
2023-04-25 12:39:37 -07:00
tarunrajput c65ab4d097 extract throwIfEventHasNoName into error-utils (#37071)
Summary:
Part of Codegen ☂️ Issue: https://github.com/facebook/react-native/issues/34872

> Extract the typeAnnotation doesn't have a name error ([Flow](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/components/events.js#L120-L122); [TypeScript](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L138-L140)) in throwIfEventHasNoName function which takes a typeAnnotation and a parser as parameters. Use it in place of the if in the above call sites.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Extract throwIfEventHasNoName error from parsers components events in error-utils

Pull Request resolved: https://github.com/facebook/react-native/pull/37071

Test Plan:
`yarn jest react-native-codegen`
<img width="810" alt="image" src="https://user-images.githubusercontent.com/34857453/234091461-67ec4187-1f38-43e0-a4ae-eb3716377665.png">

Reviewed By: cipolleschi

Differential Revision: D45247751

Pulled By: rshest

fbshipit-source-id: ad286bfbb5c9471477981ec26da77a2b0f827732
2023-04-25 04:17:10 -07:00
Pranav Yadav efc6e147f9 merge getExtendsProps & getProps fns - Flow (#36891)
Summary:
[Codegen 102] This PR is subtask of umbrella https://github.com/facebook/react-native/issues/34872. It extracts the code to compute the `extendsProps` and the props properties in Flow in a `getProps() -> {extendsProps, props}` function into the same `index.js` file. This will help unifying the `buildComponentSchema` functions between Flow and TS so we can factor it out in a later step.

## Changelog:

[INTERNAL][CHANGED] - merge `getExtendsProps` & `getProps` fns into `getProps` fn - Flow.

Pull Request resolved: https://github.com/facebook/react-native/pull/36891

Test Plan: - `yarn flow && yarn test react-native-codegen`  --> *should be green.*

Reviewed By: rshest

Differential Revision: D45044653

Pulled By: cipolleschi

fbshipit-source-id: 9fcdaef60dfbc3332d880b19c6e575d948d21986
2023-04-24 10:46:21 -07:00
Nicola Corti 50553f4e81 Re-sync repo after ShipIt change - Removal of BUCK files (#36955) 2023-04-19 12:12:04 +01:00
Genki Kondo b68f53d44f Support events with mixed payloads in codegen (#36942)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36942

Changelog:
[General][Changed] - Support mixed props for events in codegen

Reviewed By: javache

Differential Revision: D44580879

fbshipit-source-id: 52f3b12795af767c038e2db7a4faf46cf2906b95
2023-04-18 13:35:45 -07:00
gabrieldonadel e962d43233 chore: Extract logic to compute codegen TS extendsProps and props in getProps function (#36889)
Summary:
[Codegen 103] This PR extracts the logic to compute the `extendsProps` and `props` properties in TypeScript Codegen in a `getProps()` function as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[Internal] [Added] - Extract logic to compute codegen TS `extendsProps` and `props` properties in a single `getProps` function

Pull Request resolved: https://github.com/facebook/react-native/pull/36889

Test Plan: Run `yarn jest react-native-codegen` and ensure CI is green

Reviewed By: rshest

Differential Revision: D44952664

Pulled By: cipolleschi

fbshipit-source-id: fd51f0b8767efbb0071b6391e0852c19b5a984c6
2023-04-14 04:40:49 -07:00
Nicola Corti 3b4037e379 Cleanup the IS_OSS_BUILD logic from Buck files (#36899)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36899

We don't need this logic anymore as `IS_OSS_BUILD` is always false.

Changelog:
[Internal] [Changed] - Cleanup the `IS_OSS_BUILD` logic from Buck files

Reviewed By: cipolleschi

Differential Revision: D44958368

fbshipit-source-id: 1b56758879fcd7193417c5b04a819a9d72a7f1f7
2023-04-14 00:49:36 -07:00
Christoph Purrer 95dabeb53c code-gen: Enable opt-in to mobile dependencies when building for Apple Catalyst (#36851)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36851

Changelog:
[Internal]

Differential Revision: D44795138

fbshipit-source-id: 4d667531a50d41b8da8146be3c0a9b8854eb6bd1
2023-04-07 12:46:03 -07:00
Shawn Dempsey 247a913af0 Refactor react native codegen to export macOS specific deps (#36805)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36805

**Changelog:** Export macOS specific dependencies for react-native-codgen

[Internal][Changed] - RN macOS uses an older version of React Native (0.68) so we need to specify macOS specific dependencies when running codegen for RN Desktop

Reviewed By: christophpurrer

Differential Revision: D44687704

fbshipit-source-id: 9dcabc88d4abf17845db0844c952f1cb4a13e3ad
2023-04-06 17:37:53 -07:00
Zihan Chen (MSFT) 9bb71650c9 Add @react-native/codegen-typescript-test to verify .d.ts files in @react-native/codegen (1) (#36562)
Summary:
- Add a typescript project to test `CodegenSchema.d.ts`. More tests for other .d.ts files will be added in future pull requests.
- The build script scans all snapshots from `react-native/codegen`'s typescript frontend and generates .ts files for each snapshot, but they are .gitignore-ed.
- `npm run build` will build these .ts files against `CodegenSchema.d.ts` after generating them.
- A failed jest case is included to ensure CI catch it, it will be removed before merged.

bypass-github-export-checks

## Changelog:

[General] [Added] - Add react-native/codegen-typescript-test to verify .d.ts files in react-native/codegen (1)

Pull Request resolved: https://github.com/facebook/react-native/pull/36562

Test Plan:
`npm run build` in `packages/react-native-codegen-typescript-test` and see all test files appear in `__generated__`.

## Screenshot

![Untitled](https://user-images.githubusercontent.com/53799235/226757755-cab4cb29-7d22-46a1-9ecb-d6732122ed38.png)

Reviewed By: rshest

Differential Revision: D44292277

Pulled By: cipolleschi

fbshipit-source-id: 8d79fe913f9563d64c92aae7c4f4e97a24ae9a21
2023-04-05 07:38:25 -07:00
Antoine Doubovetzky 8fbcfcea8d Extract throwIfConfigNotfound and throwIfMoreThanOneConfig from findComponentConfig function (#36719)
Summary:
This PR contains tasks 96 and 97 from https://github.com/facebook/react-native/issues/34872:

>[Codegen 96 - assigned to AntoineDoubovetzky] Create a throwIfConfigNotfound in the error-utils.js file and extract the error code from [Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/components/index.js#L61-L63) and [TS](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/components/index.js#L62-L64)
 [Codegen 97 - assigned to AntoineDoubovetzky] Create a throwIfMoreThanOneConfig in the error-utils.js file and extract the error code from [Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/components/index.js#L64-L66) and [TS](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/components/index.js#L65-L67)

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal] [Changed] - Extract throwIfConfigNotfound and throwIfMoreThanOneConfig from findComponentConfig function

bypass-github-export-checks

Pull Request resolved: https://github.com/facebook/react-native/pull/36719

Test Plan: I tested using Jest and Flow commands.

Reviewed By: rshest

Differential Revision: D44539681

Pulled By: cipolleschi

fbshipit-source-id: c778ad1620d1c3f60b10c25c51efcb11173b3037
2023-04-05 06:55:47 -07:00
Ruslan Lesiutin 8a18b53bcd bump packages for 0.73 (#36556)
Summary:
Changelog: [Internal]

Publishing to check CI if bumping and aligning in the same commit will work, since these new versions are not available on npm yet, but maybe our new monorepo setup will resolve this

**Adding back `react-native/virtualized-lists` as a workspace to `xplat/js` so that it won't be resolved from npm**

#publish-packages-to-npm

Pull Request resolved: https://github.com/facebook/react-native/pull/36556

Reviewed By: cipolleschi

Differential Revision: D44255353

Pulled By: hoxyq

fbshipit-source-id: 21372487d6e9c0b2382b7cd9af835beed46b8ce1
2023-03-30 15:55:58 -07:00
gabrieldonadel 66ae98e4a4 chore: Expand Codegen emitCommonTypes function adding the remaining basic types (#36706)
Summary:
[Codegen 81] This PR expands the  `emitCommonTypes` function adding support for the remaining basic types and adding
a `convertKeywordToTypeannotation` function to the codegen Parser class and implementing it in the Flow and TypeScript parsers as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[Internal] [Added] - Expand Codegen emitCommonTypes function adding the remaining basic types

Pull Request resolved: https://github.com/facebook/react-native/pull/36706

Test Plan: Run `yarn jest react-native-codegen` and ensure CI is green

Reviewed By: christophpurrer

Differential Revision: D44504571

Pulled By: cipolleschi

fbshipit-source-id: 220d9bc0cc39614002a67dafd626e5a4878a1447
2023-03-30 03:46:47 -07:00
Phillip Pan a4fe9b2b6d deprecate ReactModuleWithSpec (#36673)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36673

Changelog: [Android][Deprecated]

in this change, we deprecate ReactModuleWithSpec because it can be replaced with the TurboModule interface which better describes our generated modules.

Reviewed By: cortinico

Differential Revision: D44450959

fbshipit-source-id: adab192593843926f35bdbeb346ef374dd80e615
2023-03-29 12:06:52 -07:00
Kyaw Thura 969a8d0799 Enrich getCommandProperties with the parser object (#36500)
Summary:
> [Codegen 101] The code of getCommandProperties is almost identical in [Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/components/index.js#L128) and [TS](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/components/index.js#L129). There are small differences between flow/ts, so we need for it to accept a Parser object. Enrich the parser object with the required methods if necessary.

## Changelog:

[Internal] [Changed] - Enrich getCommandProperties with the parser object

Pull Request resolved: https://github.com/facebook/react-native/pull/36500

Test Plan: `yarn test react-native-codegen`

Reviewed By: cortinico

Differential Revision: D44415265

Pulled By: cipolleschi

fbshipit-source-id: ed13b553a6f782beb0f1aec79bd17d865a96fac9
2023-03-29 09:28:00 -07:00
MaeIg 5ff01bc1d2 Extract getCommandTypeNameAndOptionsExpression from component folders into parsers-common (#36640)
Summary:
This PR aims to remove the duplicated logic in [flow|typescript]/components/index.js files to move it in parsers-commons. It is a task of https://github.com/facebook/react-native/issues/34872:
> [Codegen 98 - assigned to MaeIg] Extract the namedExports.map(statement => ([Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/components/index.js#L76-L108), [TS](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/components/index.js#L77-L109)) function in parser-commons, so that it accept a Parser parameter to unify the behaviors between flow and typescript. The Parser object needs to be enriched with all the methods to extract the required information from the Node, if they are not there yet.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Extract getCommandTypeNameAndOptionsExpression from component folders into parsers-common

Pull Request resolved: https://github.com/facebook/react-native/pull/36640

Test Plan:
yarn flow:
<img width="151" alt="image" src="https://user-images.githubusercontent.com/40902940/227719831-1a67f588-3bb2-48d7-8a43-4c5c8972155e.png">

yarn lint:
<img width="499" alt="image" src="https://user-images.githubusercontent.com/40902940/227719839-e5b591c3-9f3a-4da4-b3a5-67275c58584f.png">

yarn test
<img width="389" alt="image" src="https://user-images.githubusercontent.com/40902940/227719849-f3adfc4a-9215-4b1a-8807-c01801c54628.png">

Reviewed By: cipolleschi

Differential Revision: D44416032

Pulled By: rshest

fbshipit-source-id: eb682834d3da7a89661612667d9fc1df99ff3df0
2023-03-27 06:59:04 -07:00
Pieter De Baets 3759a26214 Avoid property name conflicts in event-emitter codegen (#36591)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36591

If any of the properties used in event-emitter codegen conflict with `event` or `payload`, the generated code will fail to build, even if this generated code isn't used. Since these are quite common keys, prefix them with `$` (still valid C++) to avoid conflicts.

Changelog: [General][Fixed] Resolved property name conflicts in event-emitter codegen

Reviewed By: cipolleschi

Differential Revision: D44274619

fbshipit-source-id: 45e67850c49e082d8f9b1f85bb632d45a9fd4f1d
2023-03-23 09:05:16 -07:00
Pieter De Baets 0a8164d993 Fix off-by-one error in cxx codegen (#36574)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36574

We would previously generate the following codegen for optional args

```
return static_cast<NativeAudioModuleCxxSpecJSI *>(&turboModule)->playAudio(
    rt,
    args[0].asString(rt),
    args[1].isNull() || args[1].isUndefined() ? std::nullopt : std::make_optional(args[1].asString(rt)),
    args[2].isNull() || args[2].isUndefined() ? std::nullopt : std::make_optional(args[2].asString(rt)),
    args[3].asNumber(),
    count < 4 || args[4].isNull() || args[4].isUndefined() ? std::nullopt : std::make_optional(args[4].asObject(rt)),
    count < 5 || args[5].isNull() || args[5].isUndefined() ? std::nullopt : std::make_optional(args[5].asObject(rt)),
    count < 6 || args[6].isNull() || args[6].isUndefined() ? std::nullopt : std::make_optional(args[6].asBool())
);
```

However, the counts checked are off-by-one, causing us to incorrectly process args.

Changelog: [General][Fixed] Issue with TurboModule C++ codegen with optional args

Differential Revision: D44299193

fbshipit-source-id: f00b9f5e09c2f524f9393137346c256d8b6b2979
2023-03-22 16:57:40 -07:00
Kyaw Thura 4a15f90208 Convert the emitCommonTypes implementation from a switch based implementation to a dictionary based one (#36549)
Summary:
Task from https://github.com/facebook/react-native/issues/34872
> [Codegen 80] Convert the emitCommonTypes implementation from a switch based implementation to a dictionary based one

## Changelog:

[Internal] [Changed] - Convert the emitCommonTypes implementation from a switch based implementation to a dictionary based one

Pull Request resolved: https://github.com/facebook/react-native/pull/36549

Test Plan: `yarn test react-native-codegen`

Reviewed By: NickGerleman

Differential Revision: D44244901

Pulled By: rshest

fbshipit-source-id: 50712724c72aad3bd1dae3e7c381242c4913a236
2023-03-22 13:51:39 -07:00
Tarun Chauhan 221aacd72d Move getCommandOptions and getOptions to parsers commons (#36413)
Summary:
> [Codegen 92] The getCommandOptions function in parsers/typescript/components/options.js and parsers/flow/components/options.js is the same. move it in parser-commons and use it in the original files. If the file two options.js files are empty, delete them.

> [Codegen 93] The getOptions function in parsers/typescript/components/options.js and parsers/flow/components/options.js is the same. move it in parser-commons and use it in the original files. If the file two options.js files are empty, delete them.

Part of Issue https://github.com/facebook/react-native/issues/34872

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal][Changed] - Move getCommandOptions and getOptions to parsers commons from parsers components options

Pull Request resolved: https://github.com/facebook/react-native/pull/36413

Test Plan: `yarn jest react-native-codegen`

Reviewed By: rshest

Differential Revision: D43957023

Pulled By: cipolleschi

fbshipit-source-id: 4f8bf6f8fe69b20d0fb976afee7da244ef634e12
2023-03-20 07:32:14 -07:00
Pranav Yadav 2f25261b88 Merge TS & Flow parsers' logic for Partial case to emitPartial fn & commonTypes cases into emitCommonTypes fn (#36450)
Summary:
> [Codegen 78 - Assigned to Pranav-yadav] It depends on [Codegen 75][Codegen 76][Codegen 77] Extract the logic that emits Partial values in an emitPartial function, which takes the Parsers as parameter.

>[Codegen 79 - Assigned to Pranav-yadav] It depends on [Codegen 78] Extract the basic cases logics (case Stringish, case Int32, case Double, ..., case Partial. `Flow` lines and `TypeScript` lines into a function emitCommonTypes in `parsers-primitives.js`. Make sure that the default case returns `null`. Call this function in the default: case `Flow`, `TypeScript` of the `index.js` file: if the function return something, return that from the default case; otherwise if the `emitCommonTypes` returns `null`, keep the current default implementation (throw the error).

### Changes

- merged TS & Flow parsers' logic for `Partial` case to `emitPatial` fn
- merged TS & Flow parsers' logic for below cases:
  - `Stringish`
  - `Int32`
  - `Double`
  - `Float`
  - `UnsafeObject`
  - `Object`
  - `Partial`
- into an `emitCommonTypes` fn into `parsers-primitives.js`
- add **_tests_** for `emitPartial` and `emitCommonTypes` fn's
- add `getAnnotatedElementProperties` fn to parser & impl to both TS & Flow parsers

## Changelog:

[INTERNAL] [CHANGED] - Merge TS & Flow parsers' logic for `Partial` case to `emitPatial` fn & `commonTypes` cases into `emitCommonTypes` fn

Pull Request resolved: https://github.com/facebook/react-native/pull/36450

Test Plan: - `yarn lint && yarn run flow && yarn jest react-native` ⇒ �

Reviewed By: rshest

Differential Revision: D44132308

Pulled By: cipolleschi

fbshipit-source-id: f965e85ecc5d94e57ad85334ce565a55c512fde4
2023-03-20 07:32:14 -07:00
Genki Kondo 0ae5e50e37 Support mixed props for components
Summary:
Changelog:
[Changed][General] - Support mixed props for components in codegen

Reviewed By: rickhanlonii

Differential Revision: D43894460

fbshipit-source-id: e5faf2f83e6829170cdce550e923c3c09ddff0b0
2023-03-19 16:47:22 -07:00