@react-native/codegen 0.78.0-nightly-20250107-c8552519b → 0.78.0-nightly-20250109-cfec590f6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -142,6 +142,19 @@ export type ComponentArrayTypeAnnotation = ArrayTypeAnnotation<
142
142
  | ArrayTypeAnnotation<ObjectTypeAnnotation<PropTypeAnnotation>>
143
143
  >;
144
144
 
145
+ export type ComponentCommandArrayTypeAnnotation = ArrayTypeAnnotation<
146
+ | BooleanTypeAnnotation
147
+ | StringTypeAnnotation
148
+ | DoubleTypeAnnotation
149
+ | FloatTypeAnnotation
150
+ | Int32TypeAnnotation
151
+ // Mixed is not great. This generally means its a type alias to another type
152
+ // like an object or union. Ideally we'd encode that type in the schema so the compat-check can
153
+ // validate those deeper objects for breaking changes and the generators can do something smarter.
154
+ // As of now, the generators just create ReadableMap or (const NSArray *) which are untyped
155
+ | MixedTypeAnnotation
156
+ >;
157
+
145
158
  export interface ArrayTypeAnnotation<T> {
146
159
  readonly type: 'ArrayTypeAnnotation';
147
160
  readonly elementType: T;
@@ -206,7 +219,7 @@ export type CommandParamTypeAnnotation =
206
219
  | DoubleTypeAnnotation
207
220
  | FloatTypeAnnotation
208
221
  | StringTypeAnnotation
209
- | ComponentArrayTypeAnnotation;
222
+ | ComponentCommandArrayTypeAnnotation;
210
223
 
211
224
  export interface ReservedTypeAnnotation {
212
225
  readonly type: 'ReservedTypeAnnotation';
@@ -158,6 +158,19 @@ export type ComponentArrayTypeAnnotation = ArrayTypeAnnotation<
158
158
  | ArrayTypeAnnotation<ObjectTypeAnnotation<PropTypeAnnotation>>,
159
159
  >;
160
160
 
161
+ export type ComponentCommandArrayTypeAnnotation = ArrayTypeAnnotation<
162
+ | BooleanTypeAnnotation
163
+ | StringTypeAnnotation
164
+ | DoubleTypeAnnotation
165
+ | FloatTypeAnnotation
166
+ | Int32TypeAnnotation
167
+ // Mixed is not great. This generally means its a type alias to another type
168
+ // like an object or union. Ideally we'd encode that type in the schema so the compat-check can
169
+ // validate those deeper objects for breaking changes and the generators can do something smarter.
170
+ // As of now, the generators just create ReadableMap or (const NSArray *) which are untyped
171
+ | MixedTypeAnnotation,
172
+ >;
173
+
161
174
  export type ArrayTypeAnnotation<+T> = $ReadOnly<{
162
175
  type: 'ArrayTypeAnnotation',
163
176
  elementType: T,
@@ -222,7 +235,7 @@ export type CommandParamTypeAnnotation =
222
235
  | DoubleTypeAnnotation
223
236
  | FloatTypeAnnotation
224
237
  | StringTypeAnnotation
225
- | ComponentArrayTypeAnnotation;
238
+ | ComponentCommandArrayTypeAnnotation;
226
239
 
227
240
  export type ReservedTypeAnnotation = $ReadOnly<{
228
241
  type: 'ReservedTypeAnnotation',
@@ -412,6 +425,14 @@ type NativeModuleReturnOnlyTypeAnnotation =
412
425
  | NativeModulePromiseTypeAnnotation
413
426
  | VoidTypeAnnotation;
414
427
 
428
+ // Add the allowed component reserved types to the native module union
429
+ export type CompleteReservedTypeAnnotation =
430
+ | ReservedTypeAnnotation
431
+ | {
432
+ type: 'ReservedTypeAnnotation',
433
+ name: ReservedPropTypeAnnotation['name'],
434
+ };
435
+
415
436
  // Used by compatibility check which needs to handle all possible types
416
437
  // This will eventually also include the union of all view manager types
417
438
  export type CompleteTypeAnnotation =
@@ -421,7 +442,8 @@ export type CompleteTypeAnnotation =
421
442
  | EventEmitterTypeAnnotation
422
443
  | NativeModuleEnumDeclarationWithMembers
423
444
  | UnsafeAnyTypeAnnotation
424
- // Native Module event emitters and methods
425
- | ObjectTypeAnnotation<
426
- Nullable<NativeModuleFunctionTypeAnnotation> | EventEmitterTypeAnnotation,
427
- >;
445
+ | ArrayTypeAnnotation<CompleteTypeAnnotation>
446
+ | ObjectTypeAnnotation<CompleteTypeAnnotation>
447
+ // Components
448
+ | CommandTypeAnnotation
449
+ | CompleteReservedTypeAnnotation;
@@ -1665,6 +1665,16 @@ const COMMANDS = {
1665
1665
  type: 'BooleanTypeAnnotation',
1666
1666
  },
1667
1667
  },
1668
+ {
1669
+ name: 'locations',
1670
+ optional: false,
1671
+ typeAnnotation: {
1672
+ type: 'ArrayTypeAnnotation',
1673
+ elementType: {
1674
+ type: 'MixedTypeAnnotation',
1675
+ },
1676
+ },
1677
+ },
1668
1678
  ],
1669
1679
  returnTypeAnnotation: {
1670
1680
  type: 'VoidTypeAnnotation',
@@ -1693,6 +1693,16 @@ const COMMANDS: SchemaType = {
1693
1693
  type: 'BooleanTypeAnnotation',
1694
1694
  },
1695
1695
  },
1696
+ {
1697
+ name: 'locations',
1698
+ optional: false,
1699
+ typeAnnotation: {
1700
+ type: 'ArrayTypeAnnotation',
1701
+ elementType: {
1702
+ type: 'MixedTypeAnnotation',
1703
+ },
1704
+ },
1705
+ },
1696
1706
  ],
1697
1707
  returnTypeAnnotation: {
1698
1708
  type: 'VoidTypeAnnotation',
@@ -939,10 +939,18 @@ interface NativeCommands {
939
939
  z: Double,
940
940
  animated: boolean,
941
941
  ): void;
942
+ +arrayArgs: (
943
+ viewRef: React.ElementRef<NativeType>,
944
+ booleanArray: $ReadOnlyArray<boolean>,
945
+ stringArray: $ReadOnlyArray<string>,
946
+ floatArray: $ReadOnlyArray<Float>,
947
+ intArray: $ReadOnlyArray<Int32>,
948
+ doubleArray: $ReadOnlyArray<Double>,
949
+ ) => void;
942
950
  }
943
951
 
944
952
  export const Commands = codegenNativeCommands<NativeCommands>({
945
- supportedCommands: ['handleRootTag', 'hotspotUpdate', 'scrollTo'],
953
+ supportedCommands: ['handleRootTag', 'hotspotUpdate', 'scrollTo', 'arrayArgs'],
946
954
  });
947
955
 
948
956
  export default (codegenNativeComponent<ModuleProps>(
@@ -972,6 +980,10 @@ import type {HostComponent} from 'react-native';
972
980
  export type Boolean = boolean;
973
981
  export type Int = Int32;
974
982
  export type Void = void;
983
+ export type Locations = {
984
+ x: number,
985
+ y: number,
986
+ }
975
987
 
976
988
  export type ModuleProps = $ReadOnly<{|
977
989
  ...ViewProps,
@@ -993,6 +1005,7 @@ interface NativeCommands {
993
1005
  overlayColorsReadOnly: $ReadOnlyArray<string>,
994
1006
  overlayColorsArray: Array<string>,
995
1007
  overlayColorsArrayAnnotation: string[],
1008
+ overlayLocations: $ReadOnlyArray<Locations>,
996
1009
  ) => void;
997
1010
  }
998
1011
 
@@ -951,10 +951,18 @@ interface NativeCommands {
951
951
  z: Double,
952
952
  animated: boolean,
953
953
  ): void;
954
+ +arrayArgs: (
955
+ viewRef: React.ElementRef<NativeType>,
956
+ booleanArray: $ReadOnlyArray<boolean>,
957
+ stringArray: $ReadOnlyArray<string>,
958
+ floatArray: $ReadOnlyArray<Float>,
959
+ intArray: $ReadOnlyArray<Int32>,
960
+ doubleArray: $ReadOnlyArray<Double>,
961
+ ) => void;
954
962
  }
955
963
 
956
964
  export const Commands = codegenNativeCommands<NativeCommands>({
957
- supportedCommands: ['handleRootTag', 'hotspotUpdate', 'scrollTo'],
965
+ supportedCommands: ['handleRootTag', 'hotspotUpdate', 'scrollTo', 'arrayArgs'],
958
966
  });
959
967
 
960
968
  export default (codegenNativeComponent<ModuleProps>(
@@ -985,6 +993,10 @@ import type {HostComponent} from 'react-native';
985
993
  export type Boolean = boolean;
986
994
  export type Int = Int32;
987
995
  export type Void = void;
996
+ export type Locations = {
997
+ x: number,
998
+ y: number,
999
+ }
988
1000
 
989
1001
  export type ModuleProps = $ReadOnly<{|
990
1002
  ...ViewProps,
@@ -1006,6 +1018,7 @@ interface NativeCommands {
1006
1018
  overlayColorsReadOnly: $ReadOnlyArray<string>,
1007
1019
  overlayColorsArray: Array<string>,
1008
1020
  overlayColorsArrayAnnotation: string[],
1021
+ overlayLocations: $ReadOnlyArray<Locations>,
1009
1022
  ) => void;
1010
1023
  }
1011
1024
 
@@ -81,19 +81,15 @@ function buildCommandSchema(property, types) {
81
81
  }
82
82
  returnType = {
83
83
  type: 'ArrayTypeAnnotation',
84
- elementType: {
85
- // TODO: T172453752 support complex type annotation for array element
86
- type: paramValue.typeParameters.params[0].type,
87
- },
84
+ elementType: getCommandArrayElementTypeType(
85
+ paramValue.typeParameters.params[0],
86
+ ),
88
87
  };
89
88
  break;
90
89
  case 'ArrayTypeAnnotation':
91
90
  returnType = {
92
91
  type: 'ArrayTypeAnnotation',
93
- elementType: {
94
- // TODO: T172453752 support complex type annotation for array element
95
- type: paramValue.elementType.type,
96
- },
92
+ elementType: getCommandArrayElementTypeType(paramValue.elementType),
97
93
  };
98
94
  break;
99
95
  default:
@@ -120,6 +116,64 @@ function buildCommandSchema(property, types) {
120
116
  },
121
117
  };
122
118
  }
119
+ function getCommandArrayElementTypeType(inputType) {
120
+ var _inputType$id;
121
+ // TODO: T172453752 support more complex type annotation for array element
122
+ if (typeof inputType !== 'object') {
123
+ throw new Error('Expected an object');
124
+ }
125
+ const type =
126
+ inputType === null || inputType === void 0 ? void 0 : inputType.type;
127
+ if (inputType == null || typeof type !== 'string') {
128
+ throw new Error('Command array element type must be a string');
129
+ }
130
+ switch (type) {
131
+ case 'BooleanTypeAnnotation':
132
+ return {
133
+ type: 'BooleanTypeAnnotation',
134
+ };
135
+ case 'StringTypeAnnotation':
136
+ return {
137
+ type: 'StringTypeAnnotation',
138
+ };
139
+ case 'GenericTypeAnnotation':
140
+ const name =
141
+ typeof inputType.id === 'object'
142
+ ? (_inputType$id = inputType.id) === null || _inputType$id === void 0
143
+ ? void 0
144
+ : _inputType$id.name
145
+ : null;
146
+ if (typeof name !== 'string') {
147
+ throw new Error(
148
+ 'Expected GenericTypeAnnotation AST name to be a string',
149
+ );
150
+ }
151
+ switch (name) {
152
+ case 'Int32':
153
+ return {
154
+ type: 'Int32TypeAnnotation',
155
+ };
156
+ case 'Float':
157
+ return {
158
+ type: 'FloatTypeAnnotation',
159
+ };
160
+ case 'Double':
161
+ return {
162
+ type: 'DoubleTypeAnnotation',
163
+ };
164
+ default:
165
+ // This is not a great solution. This generally means its a type alias to another type
166
+ // like an object or union. Ideally we'd encode that in the schema so the compat-check can
167
+ // validate those deeper objects for breaking changes and the generators can do something smarter.
168
+ // As of now, the generators just create ReadableMap or (const NSArray *) which are untyped
169
+ return {
170
+ type: 'MixedTypeAnnotation',
171
+ };
172
+ }
173
+ default:
174
+ throw new Error(`Unsupported array element type ${type}`);
175
+ }
176
+ }
123
177
  function getCommands(commandTypeAST, types) {
124
178
  return commandTypeAST
125
179
  .filter(property => property.type === 'ObjectTypeProperty')
@@ -13,6 +13,7 @@
13
13
  import type {
14
14
  CommandParamTypeAnnotation,
15
15
  CommandTypeAnnotation,
16
+ ComponentCommandArrayTypeAnnotation,
16
17
  NamedShape,
17
18
  } from '../../../CodegenSchema.js';
18
19
  import type {TypeDeclarationMap} from '../../utils';
@@ -109,19 +110,15 @@ function buildCommandSchema(
109
110
  }
110
111
  returnType = {
111
112
  type: 'ArrayTypeAnnotation',
112
- elementType: {
113
- // TODO: T172453752 support complex type annotation for array element
114
- type: paramValue.typeParameters.params[0].type,
115
- },
113
+ elementType: getCommandArrayElementTypeType(
114
+ paramValue.typeParameters.params[0],
115
+ ),
116
116
  };
117
117
  break;
118
118
  case 'ArrayTypeAnnotation':
119
119
  returnType = {
120
120
  type: 'ArrayTypeAnnotation',
121
- elementType: {
122
- // TODO: T172453752 support complex type annotation for array element
123
- type: paramValue.elementType.type,
124
- },
121
+ elementType: getCommandArrayElementTypeType(paramValue.elementType),
125
122
  };
126
123
  break;
127
124
  default:
@@ -151,6 +148,66 @@ function buildCommandSchema(
151
148
  };
152
149
  }
153
150
 
151
+ type Allowed = ComponentCommandArrayTypeAnnotation['elementType'];
152
+
153
+ function getCommandArrayElementTypeType(inputType: mixed): Allowed {
154
+ // TODO: T172453752 support more complex type annotation for array element
155
+ if (typeof inputType !== 'object') {
156
+ throw new Error('Expected an object');
157
+ }
158
+
159
+ const type = inputType?.type;
160
+
161
+ if (inputType == null || typeof type !== 'string') {
162
+ throw new Error('Command array element type must be a string');
163
+ }
164
+
165
+ switch (type) {
166
+ case 'BooleanTypeAnnotation':
167
+ return {
168
+ type: 'BooleanTypeAnnotation',
169
+ };
170
+ case 'StringTypeAnnotation':
171
+ return {
172
+ type: 'StringTypeAnnotation',
173
+ };
174
+ case 'GenericTypeAnnotation':
175
+ const name = typeof inputType.id === 'object' ? inputType.id?.name : null;
176
+
177
+ if (typeof name !== 'string') {
178
+ throw new Error(
179
+ 'Expected GenericTypeAnnotation AST name to be a string',
180
+ );
181
+ }
182
+
183
+ switch (name) {
184
+ case 'Int32':
185
+ return {
186
+ type: 'Int32TypeAnnotation',
187
+ };
188
+ case 'Float':
189
+ return {
190
+ type: 'FloatTypeAnnotation',
191
+ };
192
+ case 'Double':
193
+ return {
194
+ type: 'DoubleTypeAnnotation',
195
+ };
196
+ default:
197
+ // This is not a great solution. This generally means its a type alias to another type
198
+ // like an object or union. Ideally we'd encode that in the schema so the compat-check can
199
+ // validate those deeper objects for breaking changes and the generators can do something smarter.
200
+ // As of now, the generators just create ReadableMap or (const NSArray *) which are untyped
201
+ return {
202
+ type: 'MixedTypeAnnotation',
203
+ };
204
+ }
205
+
206
+ default:
207
+ throw new Error(`Unsupported array element type ${type}`);
208
+ }
209
+ }
210
+
154
211
  function getCommands(
155
212
  commandTypeAST: $ReadOnlyArray<EventTypeAST>,
156
213
  types: TypeDeclarationMap,
@@ -1052,10 +1052,18 @@ type NativeType = HostComponent<ModuleProps>;
1052
1052
  z: Double,
1053
1053
  animated: boolean,
1054
1054
  ): void;
1055
+ readonly arrayArgs: (
1056
+ viewRef: React.ElementRef<NativeType>,
1057
+ booleanArray: ReadOnlyArray<boolean>,
1058
+ stringArray: ReadOnlyArray<string>,
1059
+ floatArray: ReadOnlyArray<Float>,
1060
+ intArray: ReadOnlyArray<Int32>,
1061
+ doubleArray: ReadOnlyArray<Double>,
1062
+ ) => void;
1055
1063
  }
1056
1064
 
1057
1065
  export const Commands = codegenNativeCommands<NativeCommands>({
1058
- supportedCommands: ['handleRootTag', 'hotspotUpdate', 'scrollTo'],
1066
+ supportedCommands: ['handleRootTag', 'hotspotUpdate', 'scrollTo', 'arrayArgs'],
1059
1067
  });
1060
1068
 
1061
1069
  export default codegenNativeComponent<ModuleProps>(
@@ -1082,6 +1090,10 @@ import type {HostComponent} from 'react-native';
1082
1090
  export type Boolean = boolean;
1083
1091
  export type Int = Int32;
1084
1092
  export type Void = void;
1093
+ export type Locations = {
1094
+ x: number,
1095
+ y: number,
1096
+ }
1085
1097
 
1086
1098
  export interface ModuleProps extends ViewProps {
1087
1099
  // No props or events
@@ -1099,6 +1111,7 @@ export type AddOverlays = (
1099
1111
  overlayColorsReadOnly: ReadOnlyArray<string>,
1100
1112
  overlayColorsArray: Array<string>,
1101
1113
  overlayColorsArrayAnnotation: string[],
1114
+ overlayLocations: ReadOnlyArray<Locations>,
1102
1115
  ) => Void;
1103
1116
 
1104
1117
  interface NativeCommands {
@@ -1065,10 +1065,18 @@ type NativeType = HostComponent<ModuleProps>;
1065
1065
  z: Double,
1066
1066
  animated: boolean,
1067
1067
  ): void;
1068
+ readonly arrayArgs: (
1069
+ viewRef: React.ElementRef<NativeType>,
1070
+ booleanArray: ReadOnlyArray<boolean>,
1071
+ stringArray: ReadOnlyArray<string>,
1072
+ floatArray: ReadOnlyArray<Float>,
1073
+ intArray: ReadOnlyArray<Int32>,
1074
+ doubleArray: ReadOnlyArray<Double>,
1075
+ ) => void;
1068
1076
  }
1069
1077
 
1070
1078
  export const Commands = codegenNativeCommands<NativeCommands>({
1071
- supportedCommands: ['handleRootTag', 'hotspotUpdate', 'scrollTo'],
1079
+ supportedCommands: ['handleRootTag', 'hotspotUpdate', 'scrollTo', 'arrayArgs'],
1072
1080
  });
1073
1081
 
1074
1082
  export default codegenNativeComponent<ModuleProps>(
@@ -1096,6 +1104,10 @@ import type {HostComponent} from 'react-native';
1096
1104
  export type Boolean = boolean;
1097
1105
  export type Int = Int32;
1098
1106
  export type Void = void;
1107
+ export type Locations = {
1108
+ x: number,
1109
+ y: number,
1110
+ }
1099
1111
 
1100
1112
  export interface ModuleProps extends ViewProps {
1101
1113
  // No props or events
@@ -1113,6 +1125,7 @@ export type AddOverlays = (
1113
1125
  overlayColorsReadOnly: ReadOnlyArray<string>,
1114
1126
  overlayColorsArray: Array<string>,
1115
1127
  overlayColorsArrayAnnotation: string[],
1128
+ overlayLocations: ReadOnlyArray<Locations>,
1116
1129
  ) => Void;
1117
1130
 
1118
1131
  interface NativeCommands {
@@ -72,19 +72,15 @@ function buildCommandSchemaInternal(name, optional, parameters, types) {
72
72
  }
73
73
  returnType = {
74
74
  type: 'ArrayTypeAnnotation',
75
- elementType: getPrimitiveTypeAnnotation(
76
- // TODO: T172453752 support complex type annotation for array element
77
- paramValue.typeParameters.params[0].type,
75
+ elementType: getCommandArrayElementTypeType(
76
+ paramValue.typeParameters.params[0],
78
77
  ),
79
78
  };
80
79
  break;
81
80
  case 'TSArrayType':
82
81
  returnType = {
83
82
  type: 'ArrayTypeAnnotation',
84
- elementType: {
85
- // TODO: T172453752 support complex type annotation for array element
86
- type: getPrimitiveTypeAnnotation(paramValue.elementType.type).type,
87
- },
83
+ elementType: getCommandArrayElementTypeType(paramValue.elementType),
88
84
  };
89
85
  break;
90
86
  default:
@@ -111,6 +107,43 @@ function buildCommandSchemaInternal(name, optional, parameters, types) {
111
107
  },
112
108
  };
113
109
  }
110
+ function getCommandArrayElementTypeType(inputType) {
111
+ // TODO: T172453752 support more complex type annotation for array element
112
+
113
+ if (inputType == null || typeof inputType !== 'object') {
114
+ throw new Error(`Expected an object, received ${typeof inputType}`);
115
+ }
116
+ const type = inputType.type;
117
+ if (typeof type !== 'string') {
118
+ throw new Error('Command array element type must be a string');
119
+ }
120
+
121
+ // This is not a great solution. This generally means its a type alias to another type
122
+ // like an object or union. Ideally we'd encode that in the schema so the compat-check can
123
+ // validate those deeper objects for breaking changes and the generators can do something smarter.
124
+ // As of now, the generators just create ReadableMap or (const NSArray *) which are untyped
125
+ if (type === 'TSTypeReference') {
126
+ var _inputType$typeName;
127
+ const name =
128
+ typeof inputType.typeName === 'object'
129
+ ? (_inputType$typeName = inputType.typeName) === null ||
130
+ _inputType$typeName === void 0
131
+ ? void 0
132
+ : _inputType$typeName.name
133
+ : null;
134
+ if (typeof name !== 'string') {
135
+ throw new Error('Expected TSTypeReference AST name to be a string');
136
+ }
137
+ try {
138
+ return getPrimitiveTypeAnnotation(name);
139
+ } catch (e) {
140
+ return {
141
+ type: 'MixedTypeAnnotation',
142
+ };
143
+ }
144
+ }
145
+ return getPrimitiveTypeAnnotation(type);
146
+ }
114
147
  function buildCommandSchema(property, types) {
115
148
  if (property.type === 'TSPropertySignature') {
116
149
  const topLevelType = parseTopLevelType(
@@ -11,7 +11,9 @@
11
11
  'use strict';
12
12
 
13
13
  import type {
14
+ CommandParamTypeAnnotation,
14
15
  CommandTypeAnnotation,
16
+ ComponentCommandArrayTypeAnnotation,
15
17
  NamedShape,
16
18
  } from '../../../CodegenSchema.js';
17
19
  import type {TypeDeclarationMap} from '../../utils';
@@ -53,7 +55,7 @@ function buildCommandSchemaInternal(
53
55
  paramValue.type === 'TSTypeReference'
54
56
  ? paramValue.typeName.name
55
57
  : paramValue.type;
56
- let returnType;
58
+ let returnType: CommandParamTypeAnnotation;
57
59
 
58
60
  switch (type) {
59
61
  case 'RootTag':
@@ -78,19 +80,15 @@ function buildCommandSchemaInternal(
78
80
  }
79
81
  returnType = {
80
82
  type: 'ArrayTypeAnnotation',
81
- elementType: getPrimitiveTypeAnnotation(
82
- // TODO: T172453752 support complex type annotation for array element
83
- paramValue.typeParameters.params[0].type,
83
+ elementType: getCommandArrayElementTypeType(
84
+ paramValue.typeParameters.params[0],
84
85
  ),
85
86
  };
86
87
  break;
87
88
  case 'TSArrayType':
88
89
  returnType = {
89
90
  type: 'ArrayTypeAnnotation',
90
- elementType: {
91
- // TODO: T172453752 support complex type annotation for array element
92
- type: getPrimitiveTypeAnnotation(paramValue.elementType.type).type,
93
- },
91
+ elementType: getCommandArrayElementTypeType(paramValue.elementType),
94
92
  };
95
93
  break;
96
94
  default:
@@ -120,6 +118,44 @@ function buildCommandSchemaInternal(
120
118
  };
121
119
  }
122
120
 
121
+ function getCommandArrayElementTypeType(
122
+ inputType: mixed,
123
+ ): ComponentCommandArrayTypeAnnotation['elementType'] {
124
+ // TODO: T172453752 support more complex type annotation for array element
125
+
126
+ if (inputType == null || typeof inputType !== 'object') {
127
+ throw new Error(`Expected an object, received ${typeof inputType}`);
128
+ }
129
+
130
+ const type = inputType.type;
131
+ if (typeof type !== 'string') {
132
+ throw new Error('Command array element type must be a string');
133
+ }
134
+
135
+ // This is not a great solution. This generally means its a type alias to another type
136
+ // like an object or union. Ideally we'd encode that in the schema so the compat-check can
137
+ // validate those deeper objects for breaking changes and the generators can do something smarter.
138
+ // As of now, the generators just create ReadableMap or (const NSArray *) which are untyped
139
+ if (type === 'TSTypeReference') {
140
+ const name =
141
+ typeof inputType.typeName === 'object' ? inputType.typeName?.name : null;
142
+
143
+ if (typeof name !== 'string') {
144
+ throw new Error('Expected TSTypeReference AST name to be a string');
145
+ }
146
+
147
+ try {
148
+ return getPrimitiveTypeAnnotation(name);
149
+ } catch (e) {
150
+ return {
151
+ type: 'MixedTypeAnnotation',
152
+ };
153
+ }
154
+ }
155
+
156
+ return getPrimitiveTypeAnnotation(type);
157
+ }
158
+
123
159
  function buildCommandSchema(
124
160
  property: EventTypeAST,
125
161
  types: TypeDeclarationMap,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/codegen",
3
- "version": "0.78.0-nightly-20250107-c8552519b",
3
+ "version": "0.78.0-nightly-20250109-cfec590f6",
4
4
  "description": "Code generation tools for React Native",
5
5
  "license": "MIT",
6
6
  "repository": {