diff --git a/packages/react-native-codegen/src/CodegenSchema.js b/packages/react-native-codegen/src/CodegenSchema.js index 2d22324f82b..1c6b90f9e84 100644 --- a/packages/react-native-codegen/src/CodegenSchema.js +++ b/packages/react-native-codegen/src/CodegenSchema.js @@ -71,7 +71,7 @@ export type ComponentShape = $ReadOnly<{| extendsProps: $ReadOnlyArray, events: $ReadOnlyArray, props: $ReadOnlyArray>, - commands: $ReadOnlyArray>, + commands: $ReadOnlyArray>, |}>; export type OptionsShape = $ReadOnly<{| @@ -188,18 +188,18 @@ export type PropTypeAnnotation = |}>, |}>; -// TODO: Unify this function type annotation with NativeModule schema -export type CommandsTypeAnnotation = $ReadOnly<{| +export type CommandTypeAnnotation = $ReadOnly<{| type: 'FunctionTypeAnnotation', - params: $ReadOnlyArray, + params: $ReadOnlyArray, |}>; -export type CommandsFunctionTypeParamAnnotation = $ReadOnly<{| +// TODO: Unify this function type annotation with NativeModule schema +export type CommandFunctionTypeParamAnnotation = $ReadOnly<{| name: string, - typeAnnotation: CommandsParamTypeAnnotation, + typeAnnotation: CommandParamTypeAnnotation, |}>; -type CommandsParamTypeAnnotation = +type CommandParamTypeAnnotation = | ReservedTypeAnnotation | BooleanTypeAnnotation | Int32TypeAnnotation diff --git a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js index 9ede5b15eb7..057cf1a5cb5 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateComponentHObjCpp.js @@ -12,10 +12,10 @@ import type { NamedShape, - CommandsTypeAnnotation, + CommandTypeAnnotation, ComponentShape, SchemaType, - CommandsFunctionTypeParamAnnotation, + CommandFunctionTypeParamAnnotation, } from '../../CodegenSchema'; type FilesOutput = Map; @@ -104,7 +104,7 @@ NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END `.trim(); -function getObjCParamType(param: CommandsFunctionTypeParamAnnotation): string { +function getObjCParamType(param: CommandFunctionTypeParamAnnotation): string { const {typeAnnotation} = param; switch (typeAnnotation.type) { @@ -133,7 +133,7 @@ function getObjCParamType(param: CommandsFunctionTypeParamAnnotation): string { } function getObjCExpectedKindParamType( - param: CommandsFunctionTypeParamAnnotation, + param: CommandFunctionTypeParamAnnotation, ): string { const {typeAnnotation} = param; @@ -163,7 +163,7 @@ function getObjCExpectedKindParamType( } function getReadableExpectedKindParamType( - param: CommandsFunctionTypeParamAnnotation, + param: CommandFunctionTypeParamAnnotation, ): string { const {typeAnnotation} = param; @@ -193,7 +193,7 @@ function getReadableExpectedKindParamType( } function getObjCRightHandAssignmentParamType( - param: CommandsFunctionTypeParamAnnotation, + param: CommandFunctionTypeParamAnnotation, index: number, ): string { const {typeAnnotation} = param; @@ -253,7 +253,7 @@ function generateProtocol( } function generateConvertAndValidateParam( - param: CommandsFunctionTypeParamAnnotation, + param: CommandFunctionTypeParamAnnotation, index: number, componentName: string, ): string { @@ -274,7 +274,7 @@ function generateConvertAndValidateParam( } function generateCommandIfCase( - command: NamedShape, + command: NamedShape, componentName: string, ) { const params = command.typeAnnotation.params; diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index 528d0fb628c..55cf822b18e 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -12,7 +12,7 @@ import type { NamedShape, - CommandsTypeAnnotation, + CommandTypeAnnotation, ComponentShape, PropTypeAnnotation, SchemaType, @@ -183,7 +183,7 @@ function getCommandArgJavaType(param, index) { } function getCommandArguments( - command: NamedShape, + command: NamedShape, ): string { return [ 'view', diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js index 27c0f3de25e..ec2c97de79b 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js @@ -12,7 +12,7 @@ import type { NamedShape, - CommandsTypeAnnotation, + CommandTypeAnnotation, ComponentShape, PropTypeAnnotation, SchemaType, @@ -157,7 +157,7 @@ function getCommandArgJavaType(param) { } function getCommandArguments( - command: NamedShape, + command: NamedShape, componentName: string, ): string { return [ diff --git a/packages/react-native-codegen/src/parsers/flow/components/commands.js b/packages/react-native-codegen/src/parsers/flow/components/commands.js index c79c8e84090..1734cf75cfa 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/commands.js +++ b/packages/react-native-codegen/src/parsers/flow/components/commands.js @@ -12,7 +12,7 @@ import type { NamedShape, - CommandsTypeAnnotation, + CommandTypeAnnotation, } from '../../../CodegenSchema.js'; import type {TypeDeclarationMap} from '../utils.js'; @@ -102,7 +102,7 @@ function buildCommandSchema(property, types: TypeDeclarationMap) { function getCommands( commandTypeAST: $ReadOnlyArray, types: TypeDeclarationMap, -): $ReadOnlyArray> { +): $ReadOnlyArray> { return commandTypeAST .filter(property => property.type === 'ObjectTypeProperty') .map(property => buildCommandSchema(property, types)) diff --git a/packages/react-native-codegen/src/parsers/flow/components/schema.js b/packages/react-native-codegen/src/parsers/flow/components/schema.js index dda92acb990..d48e186d7e0 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/schema.js +++ b/packages/react-native-codegen/src/parsers/flow/components/schema.js @@ -13,7 +13,7 @@ import type { EventTypeShape, NamedShape, - CommandsTypeAnnotation, + CommandTypeAnnotation, PropTypeAnnotation, ExtendsPropsShape, SchemaType, @@ -26,7 +26,7 @@ export type ComponentSchemaBuilderConfig = $ReadOnly<{| extendsProps: $ReadOnlyArray, events: $ReadOnlyArray, props: $ReadOnlyArray>, - commands: $ReadOnlyArray>, + commands: $ReadOnlyArray>, options?: ?OptionsShape, |}>;