diff --git a/packages/react-native-codegen/src/parsers/__tests__/parsers-commons-test.js b/packages/react-native-codegen/src/parsers/__tests__/parsers-commons-test.js index 7e0237fa924..232a75c4fdc 100644 --- a/packages/react-native-codegen/src/parsers/__tests__/parsers-commons-test.js +++ b/packages/react-native-codegen/src/parsers/__tests__/parsers-commons-test.js @@ -16,7 +16,6 @@ import type {ParserType} from '../errors'; const { wrapNullable, unwrapNullable, - emitMixedTypeAnnotation, emitUnionTypeAnnotation, } = require('../parsers-commons.js'); const {UnsupportedUnionTypeAnnotationParserError} = require('../errors'); @@ -250,32 +249,6 @@ describe('assertGenericTypeAnnotationHasExactlyOneTypeParameter', () => { }); }); -describe('emitMixedTypeAnnotation', () => { - describe('when nullable is true', () => { - it('returns nullable type annotation', () => { - const result = emitMixedTypeAnnotation(true); - const expected = { - type: 'NullableTypeAnnotation', - typeAnnotation: { - type: 'MixedTypeAnnotation', - }, - }; - - expect(result).toEqual(expected); - }); - }); - describe('when nullable is false', () => { - it('returns non nullable type annotation', () => { - const result = emitMixedTypeAnnotation(false); - const expected = { - type: 'MixedTypeAnnotation', - }; - - expect(result).toEqual(expected); - }); - }); -}); - describe('emitUnionTypeAnnotation', () => { const hasteModuleName = 'SampleTurboModule'; diff --git a/packages/react-native-codegen/src/parsers/__tests__/parsers-primitives-test.js b/packages/react-native-codegen/src/parsers/__tests__/parsers-primitives-test.js index b64c48f776a..ecd36400bc6 100644 --- a/packages/react-native-codegen/src/parsers/__tests__/parsers-primitives-test.js +++ b/packages/react-native-codegen/src/parsers/__tests__/parsers-primitives-test.js @@ -23,6 +23,7 @@ const { emitVoid, emitString, emitStringish, + emitMixedTypeAnnotation, typeAliasResolution, } = require('../parsers-primitives.js'); @@ -452,3 +453,29 @@ describe('emitObject', () => { }); }); }); + +describe('emitMixedTypeAnnotation', () => { + describe('when nullable is true', () => { + it('returns nullable type annotation', () => { + const result = emitMixedTypeAnnotation(true); + const expected = { + type: 'NullableTypeAnnotation', + typeAnnotation: { + type: 'MixedTypeAnnotation', + }, + }; + + expect(result).toEqual(expected); + }); + }); + describe('when nullable is false', () => { + it('returns non nullable type annotation', () => { + const result = emitMixedTypeAnnotation(false); + const expected = { + type: 'MixedTypeAnnotation', + }; + + expect(result).toEqual(expected); + }); + }); +}); diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index cd6e2f3e440..ee7842bdb51 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -33,7 +33,6 @@ const { unwrapNullable, wrapNullable, assertGenericTypeAnnotationHasExactlyOneTypeParameter, - emitMixedTypeAnnotation, emitUnionTypeAnnotation, translateDefault, } = require('../../parsers-commons'); @@ -50,6 +49,7 @@ const { emitVoid, emitString, emitStringish, + emitMixedTypeAnnotation, typeAliasResolution, } = require('../../parsers-primitives'); diff --git a/packages/react-native-codegen/src/parsers/parsers-commons.js b/packages/react-native-codegen/src/parsers/parsers-commons.js index 28ac2725e26..cdeb0c7bf5c 100644 --- a/packages/react-native-codegen/src/parsers/parsers-commons.js +++ b/packages/react-native-codegen/src/parsers/parsers-commons.js @@ -15,7 +15,6 @@ import type { NativeModuleSchema, NativeModuleTypeAnnotation, Nullable, - NativeModuleMixedTypeAnnotation, UnionTypeAnnotationMemberType, NativeModuleUnionTypeAnnotation, } from '../CodegenSchema.js'; @@ -107,14 +106,6 @@ function assertGenericTypeAnnotationHasExactlyOneTypeParameter( } } -function emitMixedTypeAnnotation( - nullable: boolean, -): Nullable { - return wrapNullable(nullable, { - type: 'MixedTypeAnnotation', - }); -} - function remapUnionTypeAnnotationMemberNames( types: $FlowFixMe, language: ParserType, @@ -233,7 +224,6 @@ module.exports = { unwrapNullable, wrapNullable, assertGenericTypeAnnotationHasExactlyOneTypeParameter, - emitMixedTypeAnnotation, emitUnionTypeAnnotation, getKeyName, translateDefault, diff --git a/packages/react-native-codegen/src/parsers/parsers-primitives.js b/packages/react-native-codegen/src/parsers/parsers-primitives.js index 1b450d044ee..7ccfebc293a 100644 --- a/packages/react-native-codegen/src/parsers/parsers-primitives.js +++ b/packages/react-native-codegen/src/parsers/parsers-primitives.js @@ -17,6 +17,7 @@ import type { NativeModuleFunctionTypeAnnotation, NativeModuleTypeAliasTypeAnnotation, NativeModuleNumberTypeAnnotation, + NativeModuleMixedTypeAnnotation, BooleanTypeAnnotation, DoubleTypeAnnotation, Int32TypeAnnotation, @@ -80,6 +81,7 @@ function emitStringish(nullable: boolean): Nullable { type: 'StringTypeAnnotation', }); } + function emitFunction( nullable: boolean, translateFunctionTypeAnnotationValue: NativeModuleFunctionTypeAnnotation, @@ -87,6 +89,14 @@ function emitFunction( return wrapNullable(nullable, translateFunctionTypeAnnotationValue); } +function emitMixedTypeAnnotation( + nullable: boolean, +): Nullable { + return wrapNullable(nullable, { + type: 'MixedTypeAnnotation', + }); +} + function emitString(nullable: boolean): Nullable { return wrapNullable(nullable, { type: 'StringTypeAnnotation', @@ -193,5 +203,6 @@ module.exports = { emitVoid, emitString, emitStringish, + emitMixedTypeAnnotation, typeAliasResolution, }; diff --git a/packages/react-native-codegen/src/parsers/typescript/modules/index.js b/packages/react-native-codegen/src/parsers/typescript/modules/index.js index bc5aae5f65e..045b4d6df07 100644 --- a/packages/react-native-codegen/src/parsers/typescript/modules/index.js +++ b/packages/react-native-codegen/src/parsers/typescript/modules/index.js @@ -36,7 +36,6 @@ const { unwrapNullable, wrapNullable, assertGenericTypeAnnotationHasExactlyOneTypeParameter, - emitMixedTypeAnnotation, emitUnionTypeAnnotation, translateDefault, } = require('../../parsers-commons'); @@ -53,6 +52,7 @@ const { emitVoid, emitString, emitStringish, + emitMixedTypeAnnotation, typeAliasResolution, } = require('../../parsers-primitives'); const {