Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/react-native-codegen/src/CodegenSchema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ export type ComponentArrayTypeAnnotation = ArrayTypeAnnotation<
| ArrayTypeAnnotation<ObjectTypeAnnotation<PropTypeAnnotation>>
>;

export type ComponentCommandArrayTypeAnnotation = ArrayTypeAnnotation<
| BooleanTypeAnnotation
| StringTypeAnnotation
| DoubleTypeAnnotation
| FloatTypeAnnotation
| Int32TypeAnnotation
>;

export interface ArrayTypeAnnotation<T> {
readonly type: 'ArrayTypeAnnotation';
readonly elementType: T;
Expand Down Expand Up @@ -206,7 +214,7 @@ export type CommandParamTypeAnnotation =
| DoubleTypeAnnotation
| FloatTypeAnnotation
| StringTypeAnnotation
| ComponentArrayTypeAnnotation;
| ComponentCommandArrayTypeAnnotation;

export interface ReservedTypeAnnotation {
readonly type: 'ReservedTypeAnnotation';
Expand Down
25 changes: 20 additions & 5 deletions packages/react-native-codegen/src/CodegenSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ export type ComponentArrayTypeAnnotation = ArrayTypeAnnotation<
| ArrayTypeAnnotation<ObjectTypeAnnotation<PropTypeAnnotation>>,
>;

export type ComponentCommandArrayTypeAnnotation = ArrayTypeAnnotation<
| BooleanTypeAnnotation
| StringTypeAnnotation
| DoubleTypeAnnotation
| FloatTypeAnnotation
| Int32TypeAnnotation,
>;

export type ArrayTypeAnnotation<+T> = $ReadOnly<{
type: 'ArrayTypeAnnotation',
elementType: T,
Expand Down Expand Up @@ -222,7 +230,7 @@ export type CommandParamTypeAnnotation =
| DoubleTypeAnnotation
| FloatTypeAnnotation
| StringTypeAnnotation
| ComponentArrayTypeAnnotation;
| ComponentCommandArrayTypeAnnotation;

export type ReservedTypeAnnotation = $ReadOnly<{
type: 'ReservedTypeAnnotation',
Expand Down Expand Up @@ -412,6 +420,14 @@ type NativeModuleReturnOnlyTypeAnnotation =
| NativeModulePromiseTypeAnnotation
| VoidTypeAnnotation;

// Add the allowed component reserved types to the native module union
export type CompleteReservedTypeAnnotation =
| ReservedTypeAnnotation
| {
type: 'ReservedTypeAnnotation',
name: ReservedPropTypeAnnotation['name'],
};

// Used by compatibility check which needs to handle all possible types
// This will eventually also include the union of all view manager types
export type CompleteTypeAnnotation =
Expand All @@ -421,7 +437,6 @@ export type CompleteTypeAnnotation =
| EventEmitterTypeAnnotation
| NativeModuleEnumDeclarationWithMembers
| UnsafeAnyTypeAnnotation
// Native Module event emitters and methods
| ObjectTypeAnnotation<
Nullable<NativeModuleFunctionTypeAnnotation> | EventEmitterTypeAnnotation,
>;
| ArrayTypeAnnotation<CompleteTypeAnnotation>
| ObjectTypeAnnotation<CompleteTypeAnnotation>
| CompleteReservedTypeAnnotation;
Loading