Tarun Chauhan and Facebook GitHub Bot
e97fb466a0
implement checkIfInvalidModule in parsers ( #35261 )
...
Summary:
Part of the Codegen umbrella Issue https://github.com/facebook/react-native/issues/34872
> Create a checkIfInvalidModule function in the [parser.js file](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/parser.js ) and document it. Implement [this logic](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/error-utils.js#L127-L132 ) in the [FlowParser.js](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/parser.js#L15 ) and [this logic](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/error-utils.js#L136-L141 ) in the [TypeScriptParser.js](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/parser.js#L15 ). Refactor the [throwIfIncorrectModuleRegistryCallTypeParameterParserError function](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/error-utils.js#L109 ) to accept a Parser instead of a ParserType and use the newly created function instead of the if (language) logic.
## Changelog
[Internal] [Added] - Add checkIfInvalidModule in the Parser interface and implement it in both parsers. Refactor [throwIfIncorrectModuleRegistryCallTypeParameterParserError](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/error-utils.js#L109 ) to use this new function.
Pull Request resolved: https://github.com/facebook/react-native/pull/35261
Test Plan:
Run yarn jest react-native-codegen
<img width="788" alt="image" src="https://user-images.githubusercontent.com/34857453/200616752-155d638c-5ef4-4d8b-be79-07a128523910.png ">
Reviewed By: christophpurrer
Differential Revision: D41125704
Pulled By: cipolleschi
fbshipit-source-id: 029d5511050dbe975a38a890d0238cb6f3b542ea
2022-11-10 07:56:07 -08:00
Christoph Purrer and Facebook GitHub Bot
c0a06d2e6f
react-native code-gen > C++ TurboModules struct support ( #35265 )
...
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35265
This adds a templating layer for C++ TurboModules to automatically generate struct templates from TurboModule specs.
You have to define concrete types for those templates to use them in your C++ TurboModule.
E.g. for the JS flow type:
```
export type ObjectStruct = {|
a: number,
b: string,
c?: ?string,
|};
```
code-gen will now generate the following template code:
```
#pragma mark - NativeCxxModuleExampleCxxBaseObjectStruct
template <typename P0, typename P1, typename P2>
struct NativeCxxModuleExampleCxxBaseObjectStruct {
P0 a;
P1 b;
P2 c;
bool operator==(const NativeCxxModuleExampleCxxBaseObjectStruct &other) const {
return a == other.a && b == other.b && c == other.c;
}
};
template <typename P0, typename P1, typename P2>
struct NativeCxxModuleExampleCxxBaseObjectStructBridging {
static NativeCxxModuleExampleCxxBaseObjectStruct<P0, P1, P2> fromJs(
jsi::Runtime &rt,
const jsi::Object &value,
const std::shared_ptr<CallInvoker> &jsInvoker) {
NativeCxxModuleExampleCxxBaseObjectStruct<P0, P1, P2> result{
bridging::fromJs<P0>(rt, value.getProperty(rt, "a"), jsInvoker),
bridging::fromJs<P1>(rt, value.getProperty(rt, "b"), jsInvoker),
bridging::fromJs<P2>(rt, value.getProperty(rt, "c"), jsInvoker)};
return result;
}
static jsi::Object toJs(
jsi::Runtime &rt,
const NativeCxxModuleExampleCxxBaseObjectStruct<P0, P1, P2> &value) {
auto result = facebook::jsi::Object(rt);
result.setProperty(rt, "a", bridging::toJs(rt, value.a));
result.setProperty(rt, "b", bridging::toJs(rt, value.b));
if (value.c) {
result.setProperty(rt, "c", bridging::toJs(rt, value.c.value()));
}
return result;
}
};
```
and you can use it in our C++ TurboModule for example as:
```
using ObjectStruct = NativeCxxModuleExampleCxxBaseObjectStruct<
int32_t,
std::string,
std::optional<std::string>>;
template <>
struct Bridging<ObjectStruct>
: NativeCxxModuleExampleCxxBaseObjectStructBridging<
int32_t,
std::string,
std::optional<std::string>> {};
```
or as
```
using ObjectStruct = NativeCxxModuleExampleCxxBaseObjectStruct<
float,
folly::StringPiece,
std::optional<std::string>>;
template <>
struct Bridging<ObjectStruct>
: NativeCxxModuleExampleCxxBaseObjectStructBridging<
float,
folly::StringPiece,
std::optional<std::string>> {};
```
Or as
...
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D41133761
fbshipit-source-id: fdf36e51073cb46c5234f6121842c79a884899c7
2022-11-09 13:23:05 -08:00
Marco Fiorito and Facebook GitHub Bot
64ea7ce6c5
Chore: move translateFunctionTypeAnnotation into emitFunction ( #35287 )
...
Summary:
Part of https://github.com/facebook/react-native/issues/34872
In this PR was moved the translateFunctionTypeAnnotation invocation ([Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/modules/index.js#L362 ), [TypeScript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L376 )) into the emitFunction call so that the case FuntionTypeAnnotation results in a one-liner
## Changelog
[Internal] [Changed] - Move the translateFunctionTypeAnnotation invocation into the emitFunction
Pull Request resolved: https://github.com/facebook/react-native/pull/35287
Test Plan: <img width="266" alt="image" src="https://user-images.githubusercontent.com/18408823/200852605-96c233d9-b524-4b7c-bc41-5543534c296b.png ">
Reviewed By: christophpurrer
Differential Revision: D41157574
Pulled By: rshest
fbshipit-source-id: 21f6fe7dcffd30f4009ca91a6dec81bbd4b0902a
2022-11-09 12:18:31 -08:00
Pranav Yadav and Facebook GitHub Bot
5744b219c7
Extract tryParse (Flow, TypeScript) lambda into parseObjectProperty fn ( #35076 )
...
Summary:
This PR is a task of https://github.com/facebook/react-native/issues/34872
> Extract the content of the tryParse (Flow, TypeScript)lambda into a proper `parseObjectProperty` function into the parsers-commons.js file.
also,
- added new helper fn `isObjectProperty` in `parsers-commons.js` file.
- added tests for `isObjectProperty` and `parseObjectProperty` fn 's
## Changelog
[Internal] [Changed] - Extracted the content of the `tryParse` ([Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/modules/index.js#L292-L337 ), [TypeScript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L306-L351 )) lambda into a proper `parseObjectProperty` fn into the `parsers-commons.js` file.
Pull Request resolved: https://github.com/facebook/react-native/pull/35076
Test Plan:
- run
```bash
yarn lint && yarn flow && yarn test-ci
```
- and ensure everything is �
<img width="720" alt="image" src="https://user-images.githubusercontent.com/55224033/200105151-360b9b5e-52c7-4586-89b0-6860e9725f6e.png ">
Reviewed By: cortinico
Differential Revision: D40797241
Pulled By: cipolleschi
fbshipit-source-id: 48b8900ead70d5eda2496f9ce044c11a9599a177
2022-11-09 02:11:17 -08:00
Antoine Doubovetzky and Facebook GitHub Bot
8a847a30e1
Replace ternary in assertGenericTypeAnnotationHasExactlyOneTypeParameter with typeParameterInstantiation attribute in parser ( #35157 )
...
Summary:
Part of https://github.com/facebook/react-native/issues/34872 :
> Create a new function typeParameterInstantiation in the [parsers.js file](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/parser.js ) and add documentation to it. Implement it properly in the [FlowParser.js](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/parser.js#L15 ) and in the [TypeScriptParser.js](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/parser.js#L15 ). Update the signature of [assertGenericTypeAnnotationHasExactlyOneTypeParameter](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/parsers-commons.js#L67 ) function to take the Parser instead of the language and use the new function in place of the [ternary operator ?:](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/parsers-commons.js#L83 ).
There are 3 things I'm not sure about:
1. The issue suggests to create a new function. For this case I believe an attribute is simpler. Is there a reason to prefer a function ?
2. To update the tests I had to create a mocked parser. I created a new file `parserMock` (I took example on [AnimatedMock](https://github.com/facebook/react-native/blob/main/Libraries/Animated/AnimatedMock.js )). Does it seem ok ?
3. I'm not sure what to add in the documentation of `typeParameterInstantiation`
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Replace ternary in assertGenericTypeAnnotationHasExactlyOneTypeParameter with typeParameterInstantiation attribute in parser
Pull Request resolved: https://github.com/facebook/react-native/pull/35157
Test Plan: I tested using Jest and Flow commands.
Reviewed By: rshest
Differential Revision: D40889856
Pulled By: cipolleschi
fbshipit-source-id: 8d9a8e087852f98dcc3fc0ecf1d4a7153f482ce7
2022-11-08 11:55:23 -08:00
Dmitry Rykun and Facebook GitHub Bot
d62b0b463b
Bump dependency versions to 0.72.0 after the branch cut
...
Summary:
Changelog
[General][Changed] - Bump dependency versions to 0.72.0 after the branch cut.
Reviewed By: cipolleschi
Differential Revision: D41079762
fbshipit-source-id: 83e912c4eaf969c1673ccc5fa854646efa99fa4a
2022-11-07 06:57:35 -08:00
Gabriel Donadel Dall'Agnol and Facebook GitHub Bot
62244d4a1e
chore: Extract codegen translateFunctionTypeAnnotation into a common function ( #35182 )
...
Summary:
This PR extracts the codegen `translateFunctionTypeAnnotation` Flow and TypeScript functions into a single common function in the `parsers-primitives.js` file that can be used by both parsers as requested on https://github.com/facebook/react-native/issues/34872 .
## Changelog
[Internal] [Changed] - Extract codegen `translateFunctionTypeAnnotation` into a common function in the` parsers-primitives.js` file
Pull Request resolved: https://github.com/facebook/react-native/pull/35182
Test Plan:
Run `yarn jest react-native-codegen` and ensure CI is green

Reviewed By: cortinico
Differential Revision: D41030544
Pulled By: rshest
fbshipit-source-id: bc93c21e31ed4e8c3293cafe3d808d9f36cf8ecc
2022-11-07 06:14:38 -08:00
Pieter De Baets and Facebook GitHub Bot
6db3995175
Improve @Nullable annotions in Java TurboModule codegen
...
Summary:
Noticed these types could be improved based on the tests added in D40979066 (https://github.com/facebook/react-native/commit/e81c98c842380d8b72c1dc8d4a6e64f760e2a58c ).
Changelog: [Android][Fixed] Corrected Nullable annotations for parameters and return values in TurboModules codegen
Reviewed By: mdvacca, cipolleschi
Differential Revision: D40979940
fbshipit-source-id: cfc352a9e7eb9f59e2cce3d7da110a9a8d32db4b
2022-11-07 05:13:30 -08:00
Ruslan Lesiutin and Facebook GitHub Bot
d03a29ce5f
refactor(react-native-github): move ImagePickerIOS to internal ( #35199 )
...
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35199
**Changelog:**
[iOS][Removed] - Removed ImagePickerIOS module native sources
[JS][Removed] - Removed ImagePickerIOS module from react-native
Reviewed By: cortinico
Differential Revision: D40859520
fbshipit-source-id: a6a114a05574d46ea62600999bff95025ba7cdc8
2022-11-04 08:08:54 -07:00
Pranav Yadav and Facebook GitHub Bot
95e685a44d
mv emitMixedTypeAnnotation fn > parsers-primitives.js ( #35185 )
...
Summary:
This PR is a task of https://github.com/facebook/react-native/issues/34872
- Moved the [emitMixedTypeAnnotation](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/parsers-commons.js#L102 ) function to the [`parser-primitives.js` file](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/parsers-primitives.js ).
- Moved tests for the same respectively
- Fixed/Updated imports and exports for the same respectively
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[INTERNAL] [Changed] - Moved the `emitMixedTypeAnnotation` function to the `parser-primitives.js` file.
Pull Request resolved: https://github.com/facebook/react-native/pull/35185
Test Plan:
`yarn test-ci`

Reviewed By: cipolleschi
Differential Revision: D40993027
Pulled By: rshest
fbshipit-source-id: 5e025804f4ef6723396accf2f859483f76cb6cd6
2022-11-04 05:11:39 -07:00
Dmitry Rykun and Facebook GitHub Bot
8183aac0b1
Bump dependency versions before the branch cut 0.71.0
...
Summary: Changelog: [General][Changed] - Bump dependency versions.
Reviewed By: cipolleschi
Differential Revision: D40991336
fbshipit-source-id: 71c8edbeb274d095403b2f17e60f217d16fe01c0
2022-11-03 17:28:26 -07:00
Pieter De Baets and Facebook GitHub Bot
e81c98c842
Fix Cpp codegen handling of optional arguments
...
Summary:
Changelog:
[General][Fixed] - Codegen for C++ TurboModules of optional method arguments was incorrect
Reviewed By: christophpurrer
Differential Revision: D40979066
fbshipit-source-id: 5bb48dbafc14dcea21b7e0b15e3f4bb527bc8476
2022-11-03 11:20:16 -07:00
Mike Vitousek and Facebook GitHub Bot
91d58cf5b5
Codemod cycle annotations for xplat/js
...
Summary:
Add annotations using flow codemod annotate-cycles --write
Changelog: [internal]
Reviewed By: SamChou19815
Differential Revision: D40896688
fbshipit-source-id: 0c32932d17542be070360db29b7797f8e6e5978b
2022-11-01 17:13:27 -07:00
Antoine Doubovetzky and Facebook GitHub Bot
83e2126b57
Extract isModuleRegistryCall function in parsers/utils ( #35139 )
...
Summary:
This PR is a task from https://github.com/facebook/react-native/issues/34872 :
> Extract the function isModuleRegistryCall ([Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/utils.js#L175-L211 ) [TypeScript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/utils.js#L167-L203 )) into a single function in the parsers/utils.js file and replace its invocation with this new function.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Extract the function isModuleRegistryCall in parsers/utils
Pull Request resolved: https://github.com/facebook/react-native/pull/35139
Test Plan: I tested using Jest and Flow commands.
Reviewed By: rshest
Differential Revision: D40850471
Pulled By: cipolleschi
fbshipit-source-id: 34ec8ea4d7175e205315d60f200df093f1204b7b
2022-10-31 13:56:27 -07:00
Antoine Doubovetzky and Facebook GitHub Bot
56d7a87e84
Fix assertGenericTypeAnnotationHasExactlyOneTypeParameter throwing wrong error ( #35134 )
...
Summary:
1. I noticed there was a mistake in the [IncorrectlyParameterizedGenericParserError](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/errors.js#L159 ):
```
if (
genericTypeAnnotation.typeParameters.type ===
'TypeParameterInstantiation' &&
genericTypeAnnotation.typeParameters.params.length !== 1
) {
```
Here we should replace ` 'TypeParameterInstantiation'` with ` 'TSTypeParameterInstantiation'` when the language is `TypeScript`.
The result is that we get a ["Couldn't create IncorrectlyParameterizedGenericParserError"](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/errors.js#L172 ) error instead of ["Module testModuleName: Generic 'typeAnnotationName' must have exactly one type parameter."](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/parsers-commons.js#L88 ).
I added a [test case](https://github.com/facebook/react-native/commit/2f161166c033cc9de67e04cd683554b05c6173f8 ) to cover this case:
<img width="1008" alt="Capture d’écran 2022-10-30 à 13 55 56" src="https://user-images.githubusercontent.com/17070498/198879598-ab5a6092-8cbf-422a-9993-2f3f92c9d84c.png ">
2. Looking closely at where IncorrectlyParameterizedGenericParserError is used, I noticed that the logic was duplicated in [assertGenericTypeAnnotationHasExactlyOneTypeParameter](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/parsers-commons.js#L65 ).
I believe that the logic should reside in `assertGenericTypeAnnotationHasExactlyOneTypeParameter` so I split the `IncorrectlyParameterizedGenericParserError` in 2 different errors.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Fix assertGenericTypeAnnotationHasExactlyOneTypeParameter throwing wrong error
Pull Request resolved: https://github.com/facebook/react-native/pull/35134
Test Plan: I tested using Jest and Flow commands.
Reviewed By: rshest
Differential Revision: D40853200
Pulled By: cipolleschi
fbshipit-source-id: 7040e57e0a2f511ba23fd4c54beae2ccff2fa89d
2022-10-31 13:56:27 -07:00
Gabriel Donadel Dall'Agnol and Facebook GitHub Bot
ea55e3bf8d
chore: Unify codegen Flow and TS default case from translateTypeAnnotation ( #35086 )
...
Summary:
This PR unifies the Flow and TS `default:` case from codegen `translateTypeAnnotation` function into a single function
called `translateDefault` inside `parser-commons.js` as requested on https://github.com/facebook/react-native/issues/34872 .
## Changelog
[Internal] [Changed] - Unify codegen Flow and TS default case from translateTypeAnnotation
Pull Request resolved: https://github.com/facebook/react-native/pull/35086
Test Plan:
Run `yarn jest react-native-codegen` and ensure CI is green

Reviewed By: cortinico
Differential Revision: D40801612
Pulled By: cipolleschi
fbshipit-source-id: 612768d6fabe091ac428e7d8416c6da059fe1332
2022-10-31 13:56:27 -07:00
Riccardo Cipolleschi and Facebook GitHub Bot
a2166b24f8
bump codegen to v0.71.1 ( #35154 )
...
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35154
This diff bumps the codegen to v0.71.1, preparing it for the branch cut.
## Changelog
[General][Changed] - Bump codegen version
Reviewed By: dmytrorykun
Differential Revision: D40852498
fbshipit-source-id: ba1dc87f3726bc27cbd176f160c62a0bdc291433
2022-10-31 12:31:00 -07:00
Christoph Purrer and Facebook GitHub Bot
87c356d56c
Add Map / indexed object support for TypeScript parser ( #35098 )
...
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35098
Changelog:
[General][Fixed] [react-native-codegen] react-native-codegen : Add Map / indexed object support for TypeScript parser
In flow we can expose Maps via the following syntax in TM specs
`
+getMap: (arg: {[key: string]: ?number}) => {[key: string]: ?number};
`
In TypeScript writing the same spec:
`
readonly getMap: (arg: { [key: string]: number | null; }) => { [key: string]: number | null; };
`
leads to an exception the TypeScript code-gen parser
```UnsupportedObjectPropertyTypeAnnotationParserError: Module NativeTurboModuleCxx: 'ObjectTypeAnnotation' cannot contain 'TSIndexSignature'.
at react-native-github/packages/react-native-codegen/src/parsers/typescript/modules/index.js:309:23```
```
This change fixes the TypeScript parser
Reviewed By: cipolleschi
Differential Revision: D40753368
fbshipit-source-id: 0eef8ecb63d1ed049fde1e75cc6f2ec627f1f232
2022-10-30 05:48:57 -07:00
Gabriel Donadel Dall'Agnol and Facebook GitHub Bot
87d65803ab
chore: Extract codegen case 'Float' into a single emitFloat function ( #35124 )
...
Summary:
## Summary
This PR extracts the content of the codegen case `'Float'` into a single `emitFloat` function inside the `parsers-primitives.js` file and uses it in both Flow and TypeScript parsers as requested on https://github.com/facebook/react-native/issues/34872 . This also adds unit tests to the new `emitFloat` function.
## Changelog
[Internal] [Changed] - Extract the content of the case 'Float' into a single emitFloat function
Pull Request resolved: https://github.com/facebook/react-native/pull/35124
Test Plan:
Run `yarn jest react-native-codegen` and ensure CI is green

Reviewed By: rshest
Differential Revision: D40828746
Pulled By: cipolleschi
fbshipit-source-id: 9c7cecf7268f16aaef29065c1983ad9a4dd18dbe
2022-10-29 06:40:54 -07:00
Lorenzo Sciandra and Facebook GitHub Bot
cd25fb3240
chore(deps): add wanted dependencies to remove yarn warnings ( #35122 )
...
Summary:
This is take 2 of this https://github.com/facebook/react-native/pull/35088 , see this comment for why https://github.com/facebook/react-native/pull/35088#issuecomment-1295091902
I wanted to start working on a thing but this barrage of warnings was very annoying so ended up doing this instead: a very small PR to take care of some warnings during yarn install.
It doesn't change anything (the versions are the ones already used all around the repo), just makes yarn happier.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[General] [Fixed] - add wanted dependencies to remove yarn warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/35122
Test Plan:
### Before
<img width="1920" alt="Screenshot 2022-10-26 at 10 53 32" src="https://user-images.githubusercontent.com/16104054/197996489-f463be29-b35b-45cc-9d9c-2d176579fb7d.png ">
### After
<img width="947" alt="Screenshot 2022-10-26 at 10 52 19" src="https://user-images.githubusercontent.com/16104054/197996505-3d60b319-006b-45ab-83bf-2f431272fdcd.png ">
Reviewed By: cortinico
Differential Revision: D40804260
Pulled By: rshest
fbshipit-source-id: 86af14c885d6d63a0d60bb85f204d17d8757f72a
2022-10-28 13:01:48 -07:00
Antoine Doubovetzky and Facebook GitHub Bot
8c69b6cf78
Extract throwIfUnsupportedFunctionParamTypeAnnotationParserError function ( #35057 )
...
Summary:
This PR is a task from https://github.com/facebook/react-native/issues/34872 :
> Extract the UnsupportedFunctionParamTypeAnnotationParserError in its own throwing function (if it does not exists already) and reuse that function passing a proper type. Then, refactor the code using a dictionary and avoiding the three different ifs in both parsers.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Extract the UnsupportedFunctionParamTypeAnnotationParserError in its own throwing function in error-utils
Pull Request resolved: https://github.com/facebook/react-native/pull/35057
Reviewed By: lunaleaps
Differential Revision: D40721099
Pulled By: cipolleschi
fbshipit-source-id: af5e4cd275d0049047d35660559b94a27e660e40
2022-10-28 07:21:15 -07:00
youedd and Facebook GitHub Bot
0627cd69cd
Refactor translate UniontypeAnnotation ( #35050 )
...
Summary:
Part of https://github.com/facebook/react-native/issues/34872
> [Assigned to youedd] This task is more advanced than the others Create a function to unify the [unionType](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/modules/index.js#L372-L396 ) and the [TSUnionType](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L407-L431 ). This task may share some logic from the previous task. The function should accept a ParserType parameter to implement the proper logic to extract the memberType variable. Ideally, we should create a couple of supporting functions to implement those logics.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Refactor translate UniontypeAnnotation
Pull Request resolved: https://github.com/facebook/react-native/pull/35050
Test Plan:
`yarn jest react-native-codegen`

Reviewed By: cortinico
Differential Revision: D40637299
Pulled By: cipolleschi
fbshipit-source-id: 1490001a3398c3af79d465c40de3c3687f058523
2022-10-26 10:02:01 -07:00
dhruvtailor7 and Facebook GitHub Bot
cba56eadd2
Extract getConfigType function to parsers/utils.js ( #35035 )
...
Summary:
This PR is part of https://github.com/facebook/react-native/issues/34872 .
This PR contains two changes, extracting the visitor object and then factoring out the `getConfigType()` function to the `parsers/utils.js` file. Then we can reuse the same function in both flow and typescript by passing the extracted visitor object.
## Changelog
[Internal] [Changed] - Extract visitor object in the same file and factor out `getConfigType()` to `parsers/utils.js`.
Pull Request resolved: https://github.com/facebook/react-native/pull/35035
Test Plan: Output of `yarn jest react-native-codegen` ensures all passed test cases
Reviewed By: cortinico
Differential Revision: D40548855
Pulled By: cipolleschi
fbshipit-source-id: 310b8565322a4e4800a3fffc67479a9dfa45d620
2022-10-26 10:02:01 -07:00
Benny Singer and Facebook GitHub Bot
cf5addf423
Revert D40716713: chore(deps): add wanted dependencies to remove yarn warnings
...
Differential Revision:
D40716713 (https://github.com/facebook/react-native/commit/8422c5315caf5cf696791a5ad49ed0fbd37ef9df )
Original commit changeset: eeb95a91c6cd
Original Phabricator Diff: D40716713 (https://github.com/facebook/react-native/commit/8422c5315caf5cf696791a5ad49ed0fbd37ef9df )
fbshipit-source-id: e85f111e7da0381e09f8a23d3bd0d553b3a7c4a9
2022-10-26 07:22:28 -07:00
Lorenzo Sciandra and Facebook GitHub Bot
8422c5315c
chore(deps): add wanted dependencies to remove yarn warnings ( #35088 )
...
Summary:
I wanted to start working on a thing but this barrage of warnings was very annoying so ended up doing this instead: a very small PR to take care of some warnings during yarn install.
It doesn't change anything (the versions are the ones already used all around the repo), just makes yarn happier.
Also, while doing that I found a dependency that was lying there unused for 2 years so took care of it.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[General] [Fixed] - add wanted dependencies to remove yarn warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/35088
Test Plan:
### Before
<img width="1920" alt="Screenshot 2022-10-26 at 10 53 32" src="https://user-images.githubusercontent.com/16104054/197996489-f463be29-b35b-45cc-9d9c-2d176579fb7d.png ">
### After
<img width="947" alt="Screenshot 2022-10-26 at 10 52 19" src="https://user-images.githubusercontent.com/16104054/197996505-3d60b319-006b-45ab-83bf-2f431272fdcd.png ">
Reviewed By: jacdebug
Differential Revision: D40716713
Pulled By: robhogan
fbshipit-source-id: eeb95a91c6cdf37edfe868fefe4ba04aebe500ec
2022-10-26 06:42:50 -07:00
Christoph Purrer and Facebook GitHub Bot
745f3ee8c5
react-native-code-gen Add Enum Type support for iOS/Android TurboModules
...
Summary:
Adding enum support to Android/iOS generated code
Changelog:
[General][Added] - react-native-code-gen Add Enum Type support for iOS/Android TurboModules
Reviewed By: javache
Differential Revision: D38967241
fbshipit-source-id: d8bb3019dab198e16905a6422e877cd751119122
2022-10-25 08:27:47 -07:00
Riccardo Cipolleschi and Facebook GitHub Bot
5940d25cc1
Create the Parser interface ( #35036 )
...
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35036
This diff is the base to create a polimorphic behavior for TypeScript and Flow parser. This type will allow to share a lot of code between the parsers and also to keep their differences a part.
It will be the base diff/PR for further tasks in the Codegen umbrella Issue
## Changelog:
[General][Added] - Parser interface to divide parser logic.
Reviewed By: cortinico
Differential Revision: D40548707
fbshipit-source-id: e632ba52b00b43e50306e3a792a841e72e8c07f4
2022-10-25 05:01:19 -07:00
Sam Zhou and Facebook GitHub Bot
466ba91657
Implicit instantiation codemod
...
Summary: Changelog: [Internal]
Reviewed By: bradzacher
Differential Revision: D40543059
fbshipit-source-id: 4d10671d8f2734b47d2aa86646be7f543a174515
2022-10-20 19:06:09 -07:00
Zihan Chen (MSFT) and Facebook GitHub Bot
affcfa7bde
Refactor codegen: Dispatch props and events from a central place. ( #34975 )
...
Summary:
Refer to `In component, props and events pick properties from the component interface by themselves independently, I would like to reverse the direction, to have a function dispatching properties to props and events, to reduce duplicated code.
` in https://github.com/facebook/react-native/issues/34872
## Changelog
[General] [Changed] - Refactor codegen: Dispatch props and events from a central place.
Pull Request resolved: https://github.com/facebook/react-native/pull/34975
Test Plan: `yarn jest react-native-codegen` passed
Reviewed By: cortinico
Differential Revision: D40507917
Pulled By: cipolleschi
fbshipit-source-id: 71988877008ae11a01affd31b34bb3a3b88f96be
2022-10-20 12:06:50 -07:00
Jordan Brown and Facebook GitHub Bot
7884f6cfec
Implicit instantiation codemod
...
Summary:
This diff adds explicit type arguments to polymorphic function calls that do not constrain their types. This codemod will reduce the error burden that will come in a future version of flow.
This specific diff was generated by running:
```
flow codemod annotate-implicit-instantiations --write .
flow --json --pretty | jq '.errors | .[] | .message | .[] | .loc |.source' | sort | uniq | sed -e 's/"//g' | xargs hg revert
hg st -n | xargs grep "generated" | sed -e 's/:.*//g' | xargs hg revert
arc f
```
So these are the codemod results that introduced no new errors and no generated files.
Changelog: [Internal]
drop-conflicts
Reviewed By: SamChou19815
Differential Revision: D40413074
fbshipit-source-id: 42b52719978f1098169662b503dbcfd8cefdad53
2022-10-19 10:25:09 -07:00
Marco Fiorito and Facebook GitHub Bot
f628edc502
Chore/extract codegen parser more than one module exception ( #34920 )
...
Summary:
This PR is part of https://github.com/facebook/react-native/issues/34872
This PR extracts MoreThanOneModuleInterfaceParserError exception to a separate function inside an error-utils.js file
## Changelog
[Internal] [Changed] - Extract MoreThanOneModuleInterfaceParserError to a seperate function inside error-utils.js
Pull Request resolved: https://github.com/facebook/react-native/pull/34920
Test Plan: <img width="297" alt="image" src="https://user-images.githubusercontent.com/18408823/194859284-7d3ff330-c644-472e-9ae0-3b9444bc12e8.png ">
Reviewed By: cortinico
Differential Revision: D40226575
Pulled By: cipolleschi
fbshipit-source-id: 01e581abfae1ffe40e92bed8c9bedd6fe09e1aab
2022-10-19 08:54:48 -07:00
Gabriel Donadel Dall'Agnol and Facebook GitHub Bot
376ffac759
chore: Export codegen parseFile function ( #35000 )
...
Summary:
This PR export the content of the `parseFile` into a parseFile function accepting a callback to buildSchema properly in `parsers/utils.js` as requested on https://github.com/facebook/react-native/issues/34872 .
## Changelog
[Internal] [Changed] - Export ` parseFile` in to a `parseFile` function in `parsers/utils.js`
Pull Request resolved: https://github.com/facebook/react-native/pull/35000
Test Plan:
Run `yarn jest react-native-codegen` and ensure CI is green

Reviewed By: cortinico
Differential Revision: D40424857
Pulled By: cipolleschi
fbshipit-source-id: a700033d674b8be8e1af942dedf73155ea3ca025
2022-10-19 01:38:28 -07:00
MaeIg and Facebook GitHub Bot
8f484c3a62
Extract the switch(configType) block from the buildSchema function into a new function in the parsers/utils.js file ( #34992 )
...
Summary:
This PR aims to extract the switch(configType) block from the buildSchema function into a separate function in a shared file between typescript and flow. It is a task of https://github.com/facebook/react-native/issues/34872 :
> This task is more advanced than the others. Extract the switch(configType) block ([Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/index.js#L82-L119 ), [TypeScript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/index.js#L92-L129 )) from the buildSchema function into a new function in the parsers/utils.js file and use it in the two functions. Note that the new function must accept some callbacks to wrapModule/ComponentSchema and to buildModule/ComponentSchema.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Extract the switch(configType) block from the buildSchema function into a new function in the parsers/utils.js file
Pull Request resolved: https://github.com/facebook/react-native/pull/34992
Test Plan:
yarn flow:
<img width="548" alt="image" src="https://user-images.githubusercontent.com/40902940/195980663-a2d0e4bd-d2b8-464e-bbf5-3bcde553f7e8.png ">
yarn lint:
<img width="521" alt="image" src="https://user-images.githubusercontent.com/40902940/195980675-a5c67d00-a822-46a8-8bd4-e1fe4f7fb698.png ">
yarn jest react-native-codegen:
<img width="415" alt="image" src="https://user-images.githubusercontent.com/40902940/195980681-672e4447-4b33-43e8-a866-9e619ad332b1.png ">
I added new tests:
<img width="621" alt="image" src="https://user-images.githubusercontent.com/40902940/195980703-8a68756a-45ad-4931-971f-f1e83ce16a96.png ">
Reviewed By: cortinico
Differential Revision: D40429659
Pulled By: cipolleschi
fbshipit-source-id: 7e9875c129fee17c3cc5ef9c6f7990f39bfe2bf0
2022-10-19 01:38:28 -07:00
harshsiriah and Facebook GitHub Bot
32474367c2
Extracted UnsupportedFunctionReturnTypeAnnotationParserError to throwIfUnsupportedFunctionReturnTypeAnnotationParserError ( #34965 )
...
Summary:
This PR is part of https://github.com/facebook/react-native/issues/34872
This PR extracts `UnsupportedFunctionReturnTypeAnnotationParserError` exception to a separate function inside an `error-utils.js` file
## Changelog
[Internal] [Changed] - Extract `UnsupportedFunctionReturnTypeAnnotationParserError` to a seperate function inside `error-utils.js`
Pull Request resolved: https://github.com/facebook/react-native/pull/34965
Test Plan:
```sh
yarn jest react-native-codegen
```
Added unit case in `error-utils-test.js` file
<img width="939" alt="Screenshot 2022-10-13 at 11 46 54 AM" src="https://user-images.githubusercontent.com/86605635/195517350-dcb7a26d-434c-4e45-a174-ce82931073e5.png ">
Reviewed By: dmytrorykun
Differential Revision: D40338048
Pulled By: cipolleschi
fbshipit-source-id: baa41e0e96c9e17a35f316433c8d80c9bf88d334
2022-10-19 01:38:28 -07:00
Ken Tominaga and Facebook GitHub Bot
eda90e5181
Extract the content of the case 'StringTypeAnnotation' into a single … ( #34981 )
...
Summary:
This PR extracts the content of the codegen case 'String' into a single `emitString` function inside the parsers-primitives.js file and uses it in both Flow and TypeScript parsers as requested on https://github.com/facebook/react-native/issues/34872 . This also adds unit tests to the new `emitString` function.
ref: https://github.com/facebook/react-native/pull/34936
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Extract the content of the case 'StringTypeAnnotation' into a single emitString function
Pull Request resolved: https://github.com/facebook/react-native/pull/34981
Test Plan: Run `yarn jest react-native-codegen` and ensure CI is green
Reviewed By: cortinico
Differential Revision: D40376836
Pulled By: cipolleschi
fbshipit-source-id: feb1b07ec7fc2c333f5054f8cd8d18457d985257
2022-10-19 01:38:28 -07:00
Antoine Doubovetzky and Facebook GitHub Bot
790f40cfeb
Improve assertGenericTypeAnnotationHasExactlyOneTypeParameter tests ( #34942 )
...
Summary:
https://github.com/facebook/react-native/pull/34933 has been merged just after I pushed a new commit to the branch to improve tests of `assertGenericTypeAnnotationHasExactlyOneTypeParameter` function, but the last commit was not imported to the internal repository.
The `assertGenericTypeAnnotationHasExactlyOneTypeParameter` can throw different types of Error, and I believe that `.toThrow(Error)` is not specific enough. So I replaced it with `toThrowErrorMatchingInlineSnapshot()`.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Improve assertGenericTypeAnnotationHasExactlyOneTypeParameter tests in parsers-commons
Pull Request resolved: https://github.com/facebook/react-native/pull/34942
Test Plan: Some test cases were ok because the assertGenericTypeAnnotationHasExactlyOneTypeParameter function threw an Error, but for the wrong reason. I've made sure that the error displayed in the inline snapshot is the one we expect.
Reviewed By: cortinico
Differential Revision: D40384993
Pulled By: cipolleschi
fbshipit-source-id: aaa943be1e808af2c5131f7d06baf24bc3bffa31
2022-10-19 01:38:28 -07:00
dhruvtailor7 and Facebook GitHub Bot
aba6be694e
Extract UnsupportedObjectPropertyValueTypeAnnotationParserError to a throwing function ( #34917 )
...
Summary:
This PR is a part of https://github.com/facebook/react-native/issues/34872 .
Extracted the UnsupportedObjectPropertyValueTypeAnnotationParserError in its own throwing function and reuse that function passing a proper type.
## Changelog
[Internal] [Changed] - Extract the UnsupportedObjectPropertyValueTypeAnnotationParserError in its own throwing function and reuse that function passing a proper type.
Pull Request resolved: https://github.com/facebook/react-native/pull/34917
Test Plan:
Output of yarn jest react-native-codegen.
<img width="451" alt="Screenshot 2022-10-10 at 12 55 39 PM" src="https://user-images.githubusercontent.com/32268377/194816863-5220dbaa-3b63-42bf-8e62-9d7b915f7cbd.png ">
Reviewed By: cortinico
Differential Revision: D40424885
Pulled By: cipolleschi
fbshipit-source-id: 08d4d13ee3959391261fe13c190a4bb893970757
2022-10-19 01:38:28 -07:00
Sharon Zheng and Facebook GitHub Bot
42b3ab350f
fix circleci:analyze_code errors
...
Summary:
circleci analyze_code errors: https://app.circleci.com/pipelines/github/facebook/react-native/16638/workflows/76804803-ceb5-4fb3-bd24-26bbb9826827/jobs/321696
- __Image.flow and Image.ios:__ requires needed to be sorted alphabetically
- __error-utils-test.js:__ duplicate describe block title is used, i believe this was a typo
Changelog:
[Internal][Fixed] - fix circleci:analyze_code errors
Reviewed By: lunaleaps
Differential Revision: D40491001
fbshipit-source-id: a1df6ded77374f92e297d0a8866a2c4096e1196a
2022-10-18 18:56:19 -07:00
Sam Zhou and Facebook GitHub Bot
82e86c459d
Annotate empty arrays in xplat (2/n)
...
Summary: Changelog: [Internal]
Reviewed By: pieterv
Differential Revision: D40460690
fbshipit-source-id: 1e10b0bcf874dc9a3702b4d17d30d448653602ca
2022-10-18 12:49:22 -07:00
Riccardo Cipolleschi and Facebook GitHub Bot
62da9b8ce2
Backout Generate Custom Native State from Codegen
...
Summary:
This is the second diffs that backs out the Custom Native State from the Codegen. The reason why we are backing it out are:
1. It forces users to create new types in JS that are not ctually used there. For example, the NativeState you define, and eventually exports, in JS is not used anywhere in your JS code.
2. You need to put in the JS native state some types that does not exists in JS, only to have them generated by the Codegen. ImageRequest, for example, does not exists in JS, but you need it in your (iOS) state to load images
3. There are a lot of edge cases due to how C++ handles variables. Some variables needs to be created as pointers. Some others as `const &`. It does not scale to hard code all of them and there is the risk to have the same type that needs to be a pointer in some case and something else in others.
4. It is better to instruct the users on how to properly create a component with Custom State, Shadow Node and Descriptor.
## Changelog:
[General][Removed] - Back out parsing and generation of Custom Native State from Codegen
Reviewed By: cortinico
Differential Revision: D40426134
fbshipit-source-id: c368e122cc31ee8df056fe1bf6cecaab482140a4
2022-10-18 10:30:06 -07:00
youedd and Facebook GitHub Bot
633498fe9a
refactor module's platform verification ( #34961 )
...
Summary:
Part of https://github.com/facebook/react-native/issues/34872
> [Assigned to youedd] Extract the nameToValidate logic ([Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/modules/index.js#L704-L713 ), [TypeScript](https://github.com/facebook/react-native/blob/f353119113d6fc85491765ba1e90ac83cb00fd61/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L738-L747 )) into a shared function into the parser/utils.js file. Notice that you may need a callback to update the cxx boolean.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Changed] [Internal] - refactor parser module platform verification
Pull Request resolved: https://github.com/facebook/react-native/pull/34961
Test Plan:
`yarn jest react-native-codegen`

Reviewed By: cipolleschi
Differential Revision: D40319245
Pulled By: skinsshark
fbshipit-source-id: bc36cdcfa06047e1acee0d638f5756b6462d76d1
2022-10-17 11:08:06 -07:00
Mohit Charkha and Facebook GitHub Bot
9fb3700d35
Extract MisnamedModuleInterfaceParserError from Flow and Typescript into error-utils.js ( #34916 )
...
Summary:
This PR is part of https://github.com/facebook/react-native/issues/34872
This PR extracts MisnamedModuleFlowInterfaceParserError exception to a separate function inside an error-utils.js file
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Extract MisnamedModuleInterfaceParserError to a seperate function inside error-utils.js
Pull Request resolved: https://github.com/facebook/react-native/pull/34916
Test Plan:
yarn jest react-native-codegen
Added unit case in `error-utils-test.js` file
<img width="980" alt="Extract MisnamedModuleInterfaceParserError test Screenshot" src="https://user-images.githubusercontent.com/86604753/194853899-22c1ce05-fe55-4102-a83b-15c707a20000.png ">
Reviewed By: cipolleschi
Differential Revision: D40226541
Pulled By: motiz88
fbshipit-source-id: 6698ceff192c592383aa3419ac31de524c605919
2022-10-17 06:47:13 -07:00
Antoine Doubovetzky and Facebook GitHub Bot
3c8d678aad
Extract visit function to parsers/utils ( #34946 )
...
Summary:
This PR is a task from https://github.com/facebook/react-native/issues/34872 :
> Extract the visit function in a shared function in the parsers/utils.js folder. Use the new function in the Flow and TypeScript parsers.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Extract the visit function in a shared function in the parsers/utils.js
Pull Request resolved: https://github.com/facebook/react-native/pull/34946
Test Plan: I tested using jest, flow and eslint commands.
Reviewed By: NickGerleman
Differential Revision: D40276462
Pulled By: cipolleschi
fbshipit-source-id: 299cc2a3aa65a9757b217192a13838d037c497a1
2022-10-17 02:35:27 -07:00
mohitcharkha and Facebook GitHub Bot
f645404f5c
Extracted UnsupportedModulePropertyParserError into throwIfModuleTypeIsUnsupported function in error-utils.js file ( #34966 )
...
Summary:
This PR is part of https://github.com/facebook/react-native/issues/34872
This PR extracts `UnsupportedModulePropertyParserError` exception to `throwIfModuleTypeIsUnsupported` function inside `error-utils.js` file
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Extract `UnsupportedModulePropertyParserError` to `throwIfModuleTypeIsUnsupported` function inside `error-utils.js`
Pull Request resolved: https://github.com/facebook/react-native/pull/34966
Test Plan:
`yarn jest react-native-codegen`
Added unit case in `error-utils-test.js` file
<img width="939" alt="Screenshot 2022-10-13 at 12 14 19 PM" src="https://user-images.githubusercontent.com/86604753/195521643-6a197b51-7038-48f1-8b92-2c8c2786d66b.png ">
Reviewed By: christophpurrer
Differential Revision: D40337936
Pulled By: cipolleschi
fbshipit-source-id: 74fb116b48634c5e3b6c11f8b71ad59f290d959e
2022-10-14 03:09:51 -07:00
dhruvtailor7 and Facebook GitHub Bot
1e15e21348
extracted UntypedModuleRegistryCallParserError to a throwing function in error-utils.js ( #34953 )
...
Summary:
This PR is part of https://github.com/facebook/react-native/issues/34872 .
As a part of this PR, `UntypedModuleRegistryCallParserError` is separated into its own throwing function in `error-utils.js` file and is used in both Flow and TypeScript parsers
## Changelog
[Internal] [Changed] - Extract `UntypedModuleRegistryCallParserError` to a separate function inside `error-utils.js` file.
Pull Request resolved: https://github.com/facebook/react-native/pull/34953
Test Plan:
Added unit case in error-utils-test.js file to test the new function.
Output of `yarn jest react-native-codegen` ensures all passed test cases.
<img width="450" alt="Screenshot 2022-10-12 at 12 44 36 PM" src="https://user-images.githubusercontent.com/32268377/195277708-97340db3-f3d8-48a3-9a59-95d2747c67b0.png ">
Reviewed By: christophpurrer
Differential Revision: D40297017
Pulled By: cipolleschi
fbshipit-source-id: b02dcf0e110ab903a0d1831783194ae4a543075b
2022-10-14 03:09:51 -07:00
Tarun Chauhan and Facebook GitHub Bot
b87d371a38
extract emitMixedTypeAnnotation to parsers-commons ( #34954 )
...
Summary:
Create a function emitMixedTypeAnnotation into the parsers-commons.js file to put together this code from [Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/modules/index.js#L400-L404 ) and [TypeScript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L435-L440 ).
Part of https://github.com/facebook/react-native/issues/34872
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Extract emitMixedTypeAnnotation into the parsers-commons
Pull Request resolved: https://github.com/facebook/react-native/pull/34954
Test Plan:
run ```yarn jest react-native-codegen```
<img width="781" alt="image" src="https://user-images.githubusercontent.com/34857453/195291603-f138c64c-1b49-41af-a133-ee366d02706a.png ">
Reviewed By: NickGerleman
Differential Revision: D40297103
Pulled By: cipolleschi
fbshipit-source-id: 3ee3569fbfa850ac50df18b74ecc3eefbeb267c9
2022-10-14 03:09:51 -07:00
mohitcharkha and Facebook GitHub Bot
c403cd4f11
Extracted content of the case FunctionTypeAnnotation into emitFunction in parsers-primitives file ( #34950 )
...
Summary:
This PR is part of https://github.com/facebook/react-native/issues/34872
This PR extracts the content of the case `FunctionTypeAnnotation` into a single `emitFunction` function inside the parsers-primitives.js file and uses it in both Flow and TypeScript parsers
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Extract the content of the case `FunctionTypeAnnotation` into a single `emitFunction` function
Pull Request resolved: https://github.com/facebook/react-native/pull/34950
Test Plan:
Run yarn jest react-native-codegen and ensure CI is green
<img width="984" alt="Screenshot 2022-10-12 at 11 18 54 AM" src="https://user-images.githubusercontent.com/86604753/195260414-136f918f-e4b7-4fcf-b0b9-9142872f3cf9.png ">
Reviewed By: christophpurrer
Differential Revision: D40296823
Pulled By: cipolleschi
fbshipit-source-id: 3cac407d260481bd6ae7c3e46642e4c16bba3376
2022-10-14 03:09:51 -07:00
dakshbhardwaj and Facebook GitHub Bot
1eaa092daf
extracted nullguard function to parsers-util.js file ( #34952 )
...
Summary:
This PR is a part of https://github.com/facebook/react-native/issues/34872
This PR extracts Extract the `nullGuard` function ([Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L74-L76 ), [TypeScript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L74-L76 )) into a function in the `parsers-utils.js` file
## Changelog
[Internal] [Changed] - Extracted `nullGuard` function from flow and typescript to a file `parsers-utils.js`.
Pull Request resolved: https://github.com/facebook/react-native/pull/34952
Test Plan:
yarn jest react-native-codegen
<img width="1042" alt="Screenshot 2022-10-12 at 12 52 02 PM" src="https://user-images.githubusercontent.com/22423684/195277414-dc0122f4-603a-4e93-aef1-2ac0c33a960d.png ">
Reviewed By: NickGerleman
Differential Revision: D40296951
Pulled By: cipolleschi
fbshipit-source-id: 4fb305fff2e28025496b65ec697d2a59cff77bde
2022-10-14 03:09:51 -07:00
MaeIg and Facebook GitHub Bot
c388e6c689
Wrap the content of the case Array and case $ReadOnlyArray in Flow into a separate function ( #34948 )
...
Summary:
This PR aims to extract translateArrayTypeAnnotation logic into a separate function as it is done in typescript folder. This will enable us to extract translateArrayTypeAnnotation function into a shared folder in a later step. It is a task of https://github.com/facebook/react-native/issues/34872 :
> Wrap the content of the case Array: and case ReadOnlyArray in [Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/modules/index.js#L106-L107 ) into a separate function, as it is for the [TypeScript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L218-L234 ) parser. This will enable us to unify the two parsers in a later step.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Wrap the content of the case Array and case $ReadOnlyArray in Flow into a separate function
Pull Request resolved: https://github.com/facebook/react-native/pull/34948
Test Plan:
yarn flow:
<img width="645" alt="image" src="https://user-images.githubusercontent.com/40902940/195200715-7f60d927-e262-4a94-ad91-a884d37726b8.png ">
yarn lint:
<img width="502" alt="image" src="https://user-images.githubusercontent.com/40902940/195200799-7959e068-b5b7-4242-a7b1-7afd80866d7f.png ">
yarn jest react-native-codegen:
<img width="381" alt="image" src="https://user-images.githubusercontent.com/40902940/195200775-76957c19-d06d-431c-8555-889a4205374e.png ">
Reviewed By: dmytrorykun
Differential Revision: D40296730
Pulled By: cipolleschi
fbshipit-source-id: ad2d965046e25ee000ae6e07075976e5a0c78f1a
2022-10-14 03:09:51 -07:00
harshsiriah and Facebook GitHub Bot
bb519ecccb
Extracted IncorrectModuleRegistryCallTypeParameterParserError to throwIfIncorrectModuleRegistryCallTypeParameterParserError ( #34941 )
...
Summary:
This PR is part of https://github.com/facebook/react-native/issues/34872 .
This PR extracts `IncorrectModuleRegistryCallTypeParameterParserError` exception to a separate function inside an `error-utils.js` file
## Changelog
[Internal] [Changed] - Extract `IncorrectModuleRegistryCallTypeParameterParserError` to a seperate function inside `error-utils.js`
Pull Request resolved: https://github.com/facebook/react-native/pull/34941
Test Plan:
```sh
yarn jest react-native-codegen
```
Added unit case in `error-utils-test.js` file
<img width="940" alt="Screenshot 2022-10-11 at 4 42 03 PM" src="https://user-images.githubusercontent.com/86605635/195076564-3b023c17-661c-4330-805c-0216c4391d59.png ">
Reviewed By: dmytrorykun
Differential Revision: D40296642
Pulled By: cipolleschi
fbshipit-source-id: 7c7bba6a4f68e9b8fa4729a7651f22cce6d7ca6e
2022-10-14 03:09:51 -07:00