diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 3fe73a0ca60..b141a28b12f 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -62,21 +62,24 @@ export type StringEnumTypeAnnotation = $ReadOnly<{| |}>, |}>; -export type EventObjectPropertyType = $ReadOnly<{| +type NamedShape<+T> = $ReadOnly<{ name: string, optional: boolean, - typeAnnotation: - | BooleanTypeAnnotation - | StringTypeAnnotation - | DoubleTypeAnnotation - | FloatTypeAnnotation - | Int32TypeAnnotation - | StringEnumTypeAnnotation - | $ReadOnly<{| - type: 'ObjectTypeAnnotation', - properties: $ReadOnlyArray, - |}>, -|}>; + typeAnnotation: T, +}>; + +export type EventObjectPropertyType = NamedShape< + | BooleanTypeAnnotation + | StringTypeAnnotation + | DoubleTypeAnnotation + | FloatTypeAnnotation + | Int32TypeAnnotation + | StringEnumTypeAnnotation + | $ReadOnly<{| + type: 'ObjectTypeAnnotation', + properties: $ReadOnlyArray, + |}>, +>; type PropTypeTypeAnnotation = | $ReadOnly<{| @@ -161,11 +164,7 @@ type PropTypeTypeAnnotation = |}>, |}>; -export type PropTypeShape = $ReadOnly<{| - name: string, - optional: boolean, - typeAnnotation: PropTypeTypeAnnotation, -|}>; +export type PropTypeShape = NamedShape; export type EventTypeShape = $ReadOnly<{| name: string, @@ -181,11 +180,7 @@ export type EventTypeShape = $ReadOnly<{| |}>, |}>; -export type CommandTypeShape = $ReadOnly<{| - name: string, - optional: boolean, - typeAnnotation: CommandsFunctionTypeAnnotation, -|}>; +export type CommandTypeShape = NamedShape; export type OptionsShape = $ReadOnly<{| interfaceOnly?: boolean, @@ -257,11 +252,9 @@ type NativeModuleSpec = $ReadOnly<{| properties: $ReadOnlyArray, |}>; -export type NativeModulePropertySchema = $ReadOnly<{| - name: string, - optional: boolean, - typeAnnotation: Nullable, -|}>; +export type NativeModulePropertySchema = NamedShape< + Nullable, +>; export type NativeModuleAliasMap = $ReadOnly<{| [aliasName: string]: NativeModuleObjectTypeAnnotation, @@ -273,22 +266,18 @@ export type NativeModuleFunctionTypeAnnotation = $ReadOnly<{| returnTypeAnnotation: Nullable, |}>; -export type NativeModuleMethodParamSchema = $ReadOnly<{| - name: string, - optional: boolean, - typeAnnotation: Nullable, -|}>; +export type NativeModuleMethodParamSchema = NamedShape< + Nullable, +>; export type NativeModuleObjectTypeAnnotation = $ReadOnly<{| type: 'ObjectTypeAnnotation', properties: $ReadOnlyArray, |}>; -export type NativeModuleObjectTypeAnnotationPropertySchema = $ReadOnly<{| - name: string, - optional: boolean, - typeAnnotation: Nullable, -|}>; +export type NativeModuleObjectTypeAnnotationPropertySchema = NamedShape< + Nullable, +>; export type NativeModuleArrayTypeAnnotation< +T: Nullable,