Skip to content

Commit 64ea7ce

Browse files
Marcoo09facebook-github-bot
authored andcommitted
Chore: move translateFunctionTypeAnnotation into emitFunction (facebook#35287)
Summary: Part of facebook#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: facebook#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
1 parent 1f0c2c2 commit 64ea7ce

File tree

3 files changed

+41
-26
lines changed

3 files changed

+41
-26
lines changed

packages/react-native-codegen/src/parsers/flow/modules/index.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,18 +296,17 @@ function translateTypeAnnotation(
296296
return emitString(nullable);
297297
}
298298
case 'FunctionTypeAnnotation': {
299-
const translateFunctionTypeAnnotationValue: NativeModuleFunctionTypeAnnotation =
300-
translateFunctionTypeAnnotation(
301-
hasteModuleName,
302-
typeAnnotation,
303-
types,
304-
aliasMap,
305-
tryParse,
306-
cxxOnly,
307-
translateTypeAnnotation,
308-
language,
309-
);
310-
return emitFunction(nullable, translateFunctionTypeAnnotationValue);
299+
return emitFunction(
300+
nullable,
301+
hasteModuleName,
302+
typeAnnotation,
303+
types,
304+
aliasMap,
305+
tryParse,
306+
cxxOnly,
307+
translateTypeAnnotation,
308+
language,
309+
);
311310
}
312311
case 'UnionTypeAnnotation': {
313312
if (cxxOnly) {

packages/react-native-codegen/src/parsers/parsers-primitives.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,26 @@ function emitStringish(nullable: boolean): Nullable<StringTypeAnnotation> {
9999

100100
function emitFunction(
101101
nullable: boolean,
102-
translateFunctionTypeAnnotationValue: NativeModuleFunctionTypeAnnotation,
102+
hasteModuleName: string,
103+
typeAnnotation: $FlowFixMe,
104+
types: TypeDeclarationMap,
105+
aliasMap: {...NativeModuleAliasMap},
106+
tryParse: ParserErrorCapturer,
107+
cxxOnly: boolean,
108+
translateTypeAnnotation: $FlowFixMe,
109+
language: ParserType,
103110
): Nullable<NativeModuleFunctionTypeAnnotation> {
111+
const translateFunctionTypeAnnotationValue: NativeModuleFunctionTypeAnnotation =
112+
translateFunctionTypeAnnotation(
113+
hasteModuleName,
114+
typeAnnotation,
115+
types,
116+
aliasMap,
117+
tryParse,
118+
cxxOnly,
119+
translateTypeAnnotation,
120+
language,
121+
);
104122
return wrapNullable(nullable, translateFunctionTypeAnnotationValue);
105123
}
106124

packages/react-native-codegen/src/parsers/typescript/modules/index.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -302,19 +302,17 @@ function translateTypeAnnotation(
302302
return emitString(nullable);
303303
}
304304
case 'TSFunctionType': {
305-
const translateFunctionTypeAnnotationValue: NativeModuleFunctionTypeAnnotation =
306-
translateFunctionTypeAnnotation(
307-
hasteModuleName,
308-
typeAnnotation,
309-
types,
310-
aliasMap,
311-
tryParse,
312-
cxxOnly,
313-
translateTypeAnnotation,
314-
language,
315-
);
316-
317-
return emitFunction(nullable, translateFunctionTypeAnnotationValue);
305+
return emitFunction(
306+
nullable,
307+
hasteModuleName,
308+
typeAnnotation,
309+
types,
310+
aliasMap,
311+
tryParse,
312+
cxxOnly,
313+
translateTypeAnnotation,
314+
language,
315+
);
318316
}
319317
case 'TSUnionType': {
320318
if (cxxOnly) {

0 commit comments

Comments
 (0)