diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js index 2ff2a4653be..8342d6a1d77 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/__test_fixtures__/fixtures.js @@ -122,6 +122,7 @@ export interface Spec extends TurboModule { +passBool?: (arg: boolean) => void; +passNumber: (arg: number) => void; +passString: (arg: string) => void; + +passStringish: (arg: Stringish) => void; } export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-test.js.snap b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-test.js.snap index cb5f2741167..3dac11c9d9c 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/__snapshots__/module-parser-test.js.snap @@ -177,6 +177,25 @@ Object { "type": "FunctionTypeAnnotation", }, }, + Object { + "name": "passStringish", + "typeAnnotation": Object { + "optional": false, + "params": Array [ + Object { + "name": "arg", + "nullable": false, + "typeAnnotation": Object { + "type": "StringTypeAnnotation", + }, + }, + ], + "returnTypeAnnotation": Object { + "type": "VoidTypeAnnotation", + }, + "type": "FunctionTypeAnnotation", + }, + }, ], }, }, diff --git a/packages/react-native-codegen/src/parsers/flow/modules/methods.js b/packages/react-native-codegen/src/parsers/flow/modules/methods.js index b8cff9a78c6..1d0ffb3dac2 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/methods.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/methods.js @@ -97,10 +97,14 @@ function getElementTypeForArrayOrObject( }; case 'NumberTypeAnnotation': case 'BooleanTypeAnnotation': - case 'StringTypeAnnotation': return { type, }; + case 'StringTypeAnnotation': + case 'Stringish': + return { + type: 'StringTypeAnnotation', + }; case 'Int32': return { type: 'Int32TypeAnnotation', @@ -201,7 +205,6 @@ function getTypeAnnotationForParam( }; case 'NumberTypeAnnotation': case 'BooleanTypeAnnotation': - case 'StringTypeAnnotation': return { nullable, name: paramName, @@ -209,6 +212,16 @@ function getTypeAnnotationForParam( type, }, }; + + case 'StringTypeAnnotation': + case 'Stringish': + return { + nullable, + name: paramName, + typeAnnotation: { + type: 'StringTypeAnnotation', + }, + }; case 'Int32': return { nullable, @@ -298,11 +311,16 @@ function getReturnTypeAnnotation( case 'BooleanTypeAnnotation': case 'NumberTypeAnnotation': - case 'StringTypeAnnotation': case 'VoidTypeAnnotation': return { type, }; + case 'StringTypeAnnotation': + case 'Stringish': + return { + type: 'StringTypeAnnotation', + }; + case 'Int32': return { type: 'Int32TypeAnnotation',