@react-native/codegen 0.78.0-nightly-20250102-93117ea1b → 0.78.0-nightly-20250104-a6e6f5e86

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.
@@ -38,11 +38,6 @@ export interface StringTypeAnnotation {
38
38
  readonly type: 'StringTypeAnnotation';
39
39
  }
40
40
 
41
- export interface StringEnumTypeAnnotation {
42
- readonly type: 'StringEnumTypeAnnotation';
43
- readonly options: readonly string[];
44
- }
45
-
46
41
  export interface VoidTypeAnnotation {
47
42
  readonly type: 'VoidTypeAnnotation';
48
43
  }
@@ -127,16 +122,11 @@ export type EventTypeAnnotation =
127
122
  | FloatTypeAnnotation
128
123
  | Int32TypeAnnotation
129
124
  | MixedTypeAnnotation
130
- | StringEnumTypeAnnotation
125
+ | StringLiteralUnionTypeAnnotation
131
126
  | ObjectTypeAnnotation<EventTypeAnnotation>
132
- | {
133
- readonly type: 'ArrayTypeAnnotation';
134
- readonly elementType: EventTypeAnnotation
135
- };
127
+ | ArrayTypeAnnotation<EventTypeAnnotation>
136
128
 
137
- export type ArrayTypeAnnotation = {
138
- readonly type: 'ArrayTypeAnnotation';
139
- readonly elementType:
129
+ export type ComponentArrayTypeAnnotation = ArrayTypeAnnotation<
140
130
  | BooleanTypeAnnotation
141
131
  | StringTypeAnnotation
142
132
  | DoubleTypeAnnotation
@@ -149,10 +139,12 @@ export type ArrayTypeAnnotation = {
149
139
  }
150
140
  | ObjectTypeAnnotation<PropTypeAnnotation>
151
141
  | ReservedPropTypeAnnotation
152
- | {
153
- readonly type: 'ArrayTypeAnnotation';
154
- readonly elementType: ObjectTypeAnnotation<PropTypeAnnotation>;
155
- };
142
+ | ArrayTypeAnnotation<ObjectTypeAnnotation<PropTypeAnnotation>>
143
+ >;
144
+
145
+ export interface ArrayTypeAnnotation<T> {
146
+ readonly type: 'ArrayTypeAnnotation';
147
+ readonly elementType: T;
156
148
  }
157
149
 
158
150
  export type PropTypeAnnotation =
@@ -188,7 +180,7 @@ export type PropTypeAnnotation =
188
180
  }
189
181
  | ReservedPropTypeAnnotation
190
182
  | ObjectTypeAnnotation<PropTypeAnnotation>
191
- | ArrayTypeAnnotation
183
+ | ComponentArrayTypeAnnotation
192
184
  | MixedTypeAnnotation;
193
185
 
194
186
  export interface ReservedPropTypeAnnotation {
@@ -214,7 +206,7 @@ export type CommandParamTypeAnnotation =
214
206
  | DoubleTypeAnnotation
215
207
  | FloatTypeAnnotation
216
208
  | StringTypeAnnotation
217
- | ArrayTypeAnnotation;
209
+ | ComponentArrayTypeAnnotation;
218
210
 
219
211
  export interface ReservedTypeAnnotation {
220
212
  readonly type: 'ReservedTypeAnnotation';
@@ -273,14 +265,12 @@ export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation<
273
265
  Nullable<NativeModuleBaseTypeAnnotation>
274
266
  >;
275
267
 
276
- export interface NativeModuleArrayTypeAnnotation<T extends Nullable<NativeModuleBaseTypeAnnotation>> {
277
- readonly type: 'ArrayTypeAnnotation';
278
- /**
279
- * TODO(T72031674): Migrate all our NativeModule specs to not use
280
- * invalid Array ElementTypes. Then, make the elementType required.
281
- */
282
- readonly elementType: T | UnsafeAnyTypeAnnotation;
283
- }
268
+ /**
269
+ * TODO(T72031674): Migrate all our NativeModule specs to not use
270
+ * invalid Array ElementTypes. Then, make the elementType required.
271
+ */
272
+ interface NativeModuleArrayTypeAnnotation<T> extends ArrayTypeAnnotation<T | UnsafeAnyTypeAnnotation> { }
273
+
284
274
 
285
275
  export interface UnsafeAnyTypeAnnotation {
286
276
  readonly type: 'AnyTypeAnnotation',
@@ -300,7 +290,7 @@ export interface NativeModuleStringLiteralTypeAnnotation {
300
290
  readonly value: string;
301
291
  }
302
292
 
303
- export interface NativeModuleStringLiteralUnionTypeAnnotation {
293
+ export interface StringLiteralUnionTypeAnnotation {
304
294
  readonly type: 'StringLiteralUnionTypeAnnotation';
305
295
  readonly types: NativeModuleStringLiteralTypeAnnotation[];
306
296
  }
@@ -388,22 +378,19 @@ export type NativeModuleEventEmitterBaseTypeAnnotation =
388
378
  | NativeModuleNumberLiteralTypeAnnotation
389
379
  | NativeModuleStringTypeAnnotation
390
380
  | NativeModuleStringLiteralTypeAnnotation
391
- | NativeModuleStringLiteralUnionTypeAnnotation
381
+ | StringLiteralUnionTypeAnnotation
392
382
  | NativeModuleTypeAliasTypeAnnotation
393
383
  | NativeModuleGenericObjectTypeAnnotation
394
384
  | VoidTypeAnnotation;
395
385
 
396
386
  export type NativeModuleEventEmitterTypeAnnotation =
397
387
  | NativeModuleEventEmitterBaseTypeAnnotation
398
- | {
399
- readonly type: 'ArrayTypeAnnotation';
400
- readonly elementType: NativeModuleEventEmitterBaseTypeAnnotation;
401
- };
388
+ | ArrayTypeAnnotation<NativeModuleEventEmitterBaseTypeAnnotation>;
402
389
 
403
390
  export type NativeModuleBaseTypeAnnotation =
404
- | NativeModuleStringTypeAnnotation
391
+ NativeModuleStringTypeAnnotation
405
392
  | NativeModuleStringLiteralTypeAnnotation
406
- | NativeModuleStringLiteralUnionTypeAnnotation
393
+ | StringLiteralUnionTypeAnnotation
407
394
  | NativeModuleNumberTypeAnnotation
408
395
  | NativeModuleNumberLiteralTypeAnnotation
409
396
  | NativeModuleInt32TypeAnnotation
@@ -414,10 +401,10 @@ export type NativeModuleBaseTypeAnnotation =
414
401
  | NativeModuleGenericObjectTypeAnnotation
415
402
  | ReservedTypeAnnotation
416
403
  | NativeModuleTypeAliasTypeAnnotation
417
- | NativeModuleArrayTypeAnnotation<Nullable<NativeModuleBaseTypeAnnotation>>
418
404
  | NativeModuleObjectTypeAnnotation
419
405
  | NativeModuleUnionTypeAnnotation
420
- | NativeModuleMixedTypeAnnotation;
406
+ | NativeModuleMixedTypeAnnotation
407
+ | NativeModuleArrayTypeAnnotation<NativeModuleBaseTypeAnnotation>;
421
408
 
422
409
  export type NativeModuleParamTypeAnnotation =
423
410
  | NativeModuleBaseTypeAnnotation
@@ -56,11 +56,6 @@ export type StringLiteralUnionTypeAnnotation = $ReadOnly<{
56
56
  types: $ReadOnlyArray<StringLiteralTypeAnnotation>,
57
57
  }>;
58
58
 
59
- export type StringEnumTypeAnnotation = $ReadOnly<{
60
- type: 'StringEnumTypeAnnotation',
61
- options: $ReadOnlyArray<string>,
62
- }>;
63
-
64
59
  export type VoidTypeAnnotation = $ReadOnly<{
65
60
  type: 'VoidTypeAnnotation',
66
61
  }>;
@@ -143,32 +138,29 @@ export type EventTypeAnnotation =
143
138
  | FloatTypeAnnotation
144
139
  | Int32TypeAnnotation
145
140
  | MixedTypeAnnotation
146
- | StringEnumTypeAnnotation
141
+ | StringLiteralUnionTypeAnnotation
147
142
  | ObjectTypeAnnotation<EventTypeAnnotation>
143
+ | ArrayTypeAnnotation<EventTypeAnnotation>;
144
+
145
+ export type ComponentArrayTypeAnnotation = ArrayTypeAnnotation<
146
+ | BooleanTypeAnnotation
147
+ | StringTypeAnnotation
148
+ | DoubleTypeAnnotation
149
+ | FloatTypeAnnotation
150
+ | Int32TypeAnnotation
148
151
  | $ReadOnly<{
149
- type: 'ArrayTypeAnnotation',
150
- elementType: EventTypeAnnotation,
151
- }>;
152
+ type: 'StringEnumTypeAnnotation',
153
+ default: string,
154
+ options: $ReadOnlyArray<string>,
155
+ }>
156
+ | ObjectTypeAnnotation<PropTypeAnnotation>
157
+ | ReservedPropTypeAnnotation
158
+ | ArrayTypeAnnotation<ObjectTypeAnnotation<PropTypeAnnotation>>,
159
+ >;
152
160
 
153
- export type ArrayTypeAnnotation = $ReadOnly<{
161
+ export type ArrayTypeAnnotation<+T> = $ReadOnly<{
154
162
  type: 'ArrayTypeAnnotation',
155
- elementType:
156
- | BooleanTypeAnnotation
157
- | StringTypeAnnotation
158
- | DoubleTypeAnnotation
159
- | FloatTypeAnnotation
160
- | Int32TypeAnnotation
161
- | $ReadOnly<{
162
- type: 'StringEnumTypeAnnotation',
163
- default: string,
164
- options: $ReadOnlyArray<string>,
165
- }>
166
- | ObjectTypeAnnotation<PropTypeAnnotation>
167
- | ReservedPropTypeAnnotation
168
- | $ReadOnly<{
169
- type: 'ArrayTypeAnnotation',
170
- elementType: ObjectTypeAnnotation<PropTypeAnnotation>,
171
- }>,
163
+ elementType: T,
172
164
  }>;
173
165
 
174
166
  export type PropTypeAnnotation =
@@ -204,7 +196,7 @@ export type PropTypeAnnotation =
204
196
  }>
205
197
  | ReservedPropTypeAnnotation
206
198
  | ObjectTypeAnnotation<PropTypeAnnotation>
207
- | ArrayTypeAnnotation
199
+ | ComponentArrayTypeAnnotation
208
200
  | MixedTypeAnnotation;
209
201
 
210
202
  export type ReservedPropTypeAnnotation = $ReadOnly<{
@@ -230,7 +222,7 @@ export type CommandParamTypeAnnotation =
230
222
  | DoubleTypeAnnotation
231
223
  | FloatTypeAnnotation
232
224
  | StringTypeAnnotation
233
- | ArrayTypeAnnotation;
225
+ | ComponentArrayTypeAnnotation;
234
226
 
235
227
  export type ReservedTypeAnnotation = $ReadOnly<{
236
228
  type: 'ReservedTypeAnnotation',
@@ -292,14 +284,14 @@ export type NativeModuleObjectTypeAnnotation = ObjectTypeAnnotation<
292
284
 
293
285
  export type NativeModuleArrayTypeAnnotation<
294
286
  +T: Nullable<NativeModuleBaseTypeAnnotation>,
295
- > = $ReadOnly<{
296
- type: 'ArrayTypeAnnotation',
287
+ > = ArrayTypeAnnotation<
288
+ | T
297
289
  /**
298
290
  * TODO(T72031674): Migrate all our NativeModule specs to not use
299
291
  * invalid Array ElementTypes. Then, make the elementType required.
300
292
  */
301
- elementType: T | UnsafeAnyTypeAnnotation,
302
- }>;
293
+ | UnsafeAnyTypeAnnotation,
294
+ >;
303
295
 
304
296
  export type UnsafeAnyTypeAnnotation = {
305
297
  type: 'AnyTypeAnnotation',
@@ -379,10 +371,7 @@ type NativeModuleEventEmitterBaseTypeAnnotation =
379
371
 
380
372
  export type NativeModuleEventEmitterTypeAnnotation =
381
373
  | NativeModuleEventEmitterBaseTypeAnnotation
382
- | {
383
- type: 'ArrayTypeAnnotation',
384
- elementType: NativeModuleEventEmitterBaseTypeAnnotation,
385
- };
374
+ | ArrayTypeAnnotation<NativeModuleEventEmitterBaseTypeAnnotation>;
386
375
 
387
376
  export type NativeModuleBaseTypeAnnotation =
388
377
  | StringTypeAnnotation
@@ -44,7 +44,7 @@ function getCppArrayTypeForAnnotation(typeElement, structParts) {
44
44
  case 'Int32TypeAnnotation':
45
45
  case 'MixedTypeAnnotation':
46
46
  return `std::vector<${getCppTypeForAnnotation(typeElement.type)}>`;
47
- case 'StringEnumTypeAnnotation':
47
+ case 'StringLiteralUnionTypeAnnotation':
48
48
  case 'ObjectTypeAnnotation':
49
49
  if (!structParts) {
50
50
  throw new Error(
@@ -61,7 +61,7 @@ function getCppArrayTypeForAnnotation(
61
61
  case 'Int32TypeAnnotation':
62
62
  case 'MixedTypeAnnotation':
63
63
  return `std::vector<${getCppTypeForAnnotation(typeElement.type)}>`;
64
- case 'StringEnumTypeAnnotation':
64
+ case 'StringLiteralUnionTypeAnnotation':
65
65
  case 'ObjectTypeAnnotation':
66
66
  if (!structParts) {
67
67
  throw new Error(
@@ -170,7 +170,7 @@ function handleArrayElementType(
170
170
  loopLocalVariable,
171
171
  val => `jsi::valueFromDynamic(runtime, ${val})`,
172
172
  );
173
- case 'StringEnumTypeAnnotation':
173
+ case 'StringLiteralUnionTypeAnnotation':
174
174
  return setValueAtIndex(
175
175
  propertyName,
176
176
  indexVariable,
@@ -280,7 +280,7 @@ function generateSetters(
280
280
  usingEvent,
281
281
  prop => `jsi::valueFromDynamic(runtime, ${prop})`,
282
282
  );
283
- case 'StringEnumTypeAnnotation':
283
+ case 'StringLiteralUnionTypeAnnotation':
284
284
  return generateSetter(
285
285
  parentPropertyName,
286
286
  eventProperty.name,
@@ -207,7 +207,7 @@ function handleArrayElementType(
207
207
  loopLocalVariable,
208
208
  val => `jsi::valueFromDynamic(runtime, ${val})`,
209
209
  );
210
- case 'StringEnumTypeAnnotation':
210
+ case 'StringLiteralUnionTypeAnnotation':
211
211
  return setValueAtIndex(
212
212
  propertyName,
213
213
  indexVariable,
@@ -320,7 +320,7 @@ function generateSetters(
320
320
  usingEvent,
321
321
  prop => `jsi::valueFromDynamic(runtime, ${prop})`,
322
322
  );
323
- case 'StringEnumTypeAnnotation':
323
+ case 'StringLiteralUnionTypeAnnotation':
324
324
  return generateSetter(
325
325
  parentPropertyName,
326
326
  eventProperty.name,
@@ -77,7 +77,7 @@ function getNativeTypeFromAnnotation(componentName, eventProperty, nameParts) {
77
77
  case 'FloatTypeAnnotation':
78
78
  case 'MixedTypeAnnotation':
79
79
  return getCppTypeForAnnotation(type);
80
- case 'StringEnumTypeAnnotation':
80
+ case 'StringLiteralUnionTypeAnnotation':
81
81
  case 'ObjectTypeAnnotation':
82
82
  return generateEventStructName([...nameParts, eventProperty.name]);
83
83
  case 'ArrayTypeAnnotation':
@@ -130,8 +130,12 @@ function handleGenerateStructForArray(
130
130
  nameParts.concat([name]),
131
131
  nullthrows(elementType.properties),
132
132
  );
133
- } else if (elementType.type === 'StringEnumTypeAnnotation') {
134
- generateEnum(structs, elementType.options, nameParts.concat([name]));
133
+ } else if (elementType.type === 'StringLiteralUnionTypeAnnotation') {
134
+ generateEnum(
135
+ structs,
136
+ elementType.types.map(literal => literal.value),
137
+ nameParts.concat([name]),
138
+ );
135
139
  } else if (elementType.type === 'ArrayTypeAnnotation') {
136
140
  handleGenerateStructForArray(
137
141
  structs,
@@ -182,8 +186,12 @@ function generateStruct(structs, componentName, nameParts, properties) {
182
186
  nullthrows(typeAnnotation.properties),
183
187
  );
184
188
  return;
185
- case 'StringEnumTypeAnnotation':
186
- generateEnum(structs, typeAnnotation.options, nameParts.concat([name]));
189
+ case 'StringLiteralUnionTypeAnnotation':
190
+ generateEnum(
191
+ structs,
192
+ typeAnnotation.types.map(literal => literal.value),
193
+ nameParts.concat([name]),
194
+ );
187
195
  return;
188
196
  default:
189
197
  typeAnnotation.type;
@@ -128,7 +128,7 @@ function getNativeTypeFromAnnotation(
128
128
  case 'FloatTypeAnnotation':
129
129
  case 'MixedTypeAnnotation':
130
130
  return getCppTypeForAnnotation(type);
131
- case 'StringEnumTypeAnnotation':
131
+ case 'StringLiteralUnionTypeAnnotation':
132
132
  case 'ObjectTypeAnnotation':
133
133
  return generateEventStructName([...nameParts, eventProperty.name]);
134
134
  case 'ArrayTypeAnnotation':
@@ -188,8 +188,12 @@ function handleGenerateStructForArray(
188
188
  nameParts.concat([name]),
189
189
  nullthrows(elementType.properties),
190
190
  );
191
- } else if (elementType.type === 'StringEnumTypeAnnotation') {
192
- generateEnum(structs, elementType.options, nameParts.concat([name]));
191
+ } else if (elementType.type === 'StringLiteralUnionTypeAnnotation') {
192
+ generateEnum(
193
+ structs,
194
+ elementType.types.map(literal => literal.value),
195
+ nameParts.concat([name]),
196
+ );
193
197
  } else if (elementType.type === 'ArrayTypeAnnotation') {
194
198
  handleGenerateStructForArray(
195
199
  structs,
@@ -247,8 +251,12 @@ function generateStruct(
247
251
  nullthrows(typeAnnotation.properties),
248
252
  );
249
253
  return;
250
- case 'StringEnumTypeAnnotation':
251
- generateEnum(structs, typeAnnotation.options, nameParts.concat([name]));
254
+ case 'StringLiteralUnionTypeAnnotation':
255
+ generateEnum(
256
+ structs,
257
+ typeAnnotation.types.map(literal => literal.value),
258
+ nameParts.concat([name]),
259
+ );
252
260
  return;
253
261
  default:
254
262
  (typeAnnotation.type: empty);
@@ -11,8 +11,8 @@
11
11
  'use strict';
12
12
 
13
13
  import type {
14
- ArrayTypeAnnotation,
15
14
  BooleanTypeAnnotation,
15
+ ComponentArrayTypeAnnotation,
16
16
  DoubleTypeAnnotation,
17
17
  FloatTypeAnnotation,
18
18
  Int32TypeAnnotation,
@@ -111,8 +111,10 @@ class PojoCollector {
111
111
  }
112
112
  case 'ArrayTypeAnnotation': {
113
113
  const arrayTypeAnnotation = typeAnnotation;
114
- const elementType: $PropertyType<ArrayTypeAnnotation, 'elementType'> =
115
- arrayTypeAnnotation.elementType;
114
+ const elementType: $PropertyType<
115
+ ComponentArrayTypeAnnotation,
116
+ 'elementType',
117
+ > = arrayTypeAnnotation.elementType;
116
118
 
117
119
  const pojoElementType = (() => {
118
120
  switch (elementType.type) {
@@ -1241,8 +1241,17 @@ const EVENT_PROPS = {
1241
1241
  typeAnnotation: {
1242
1242
  type: 'ArrayTypeAnnotation',
1243
1243
  elementType: {
1244
- type: 'StringEnumTypeAnnotation',
1245
- options: ['YES', 'NO'],
1244
+ type: 'StringLiteralUnionTypeAnnotation',
1245
+ types: [
1246
+ {
1247
+ type: 'StringLiteralTypeAnnotation',
1248
+ value: 'YES',
1249
+ },
1250
+ {
1251
+ type: 'StringLiteralTypeAnnotation',
1252
+ value: 'NO',
1253
+ },
1254
+ ],
1246
1255
  },
1247
1256
  },
1248
1257
  },
@@ -1342,8 +1351,17 @@ const EVENT_PROPS = {
1342
1351
  name: 'orientation',
1343
1352
  optional: false,
1344
1353
  typeAnnotation: {
1345
- type: 'StringEnumTypeAnnotation',
1346
- options: ['landscape', 'portrait'],
1354
+ type: 'StringLiteralUnionTypeAnnotation',
1355
+ types: [
1356
+ {
1357
+ type: 'StringLiteralTypeAnnotation',
1358
+ value: 'landscape',
1359
+ },
1360
+ {
1361
+ type: 'StringLiteralTypeAnnotation',
1362
+ value: 'portrait',
1363
+ },
1364
+ ],
1347
1365
  },
1348
1366
  },
1349
1367
  ],
@@ -1263,8 +1263,17 @@ const EVENT_PROPS: SchemaType = {
1263
1263
  typeAnnotation: {
1264
1264
  type: 'ArrayTypeAnnotation',
1265
1265
  elementType: {
1266
- type: 'StringEnumTypeAnnotation',
1267
- options: ['YES', 'NO'],
1266
+ type: 'StringLiteralUnionTypeAnnotation',
1267
+ types: [
1268
+ {
1269
+ type: 'StringLiteralTypeAnnotation',
1270
+ value: 'YES',
1271
+ },
1272
+ {
1273
+ type: 'StringLiteralTypeAnnotation',
1274
+ value: 'NO',
1275
+ },
1276
+ ],
1268
1277
  },
1269
1278
  },
1270
1279
  },
@@ -1364,8 +1373,17 @@ const EVENT_PROPS: SchemaType = {
1364
1373
  name: 'orientation',
1365
1374
  optional: false,
1366
1375
  typeAnnotation: {
1367
- type: 'StringEnumTypeAnnotation',
1368
- options: ['landscape', 'portrait'],
1376
+ type: 'StringLiteralUnionTypeAnnotation',
1377
+ types: [
1378
+ {
1379
+ type: 'StringLiteralTypeAnnotation',
1380
+ value: 'landscape',
1381
+ },
1382
+ {
1383
+ type: 'StringLiteralTypeAnnotation',
1384
+ value: 'portrait',
1385
+ },
1386
+ ],
1369
1387
  },
1370
1388
  },
1371
1389
  ],
@@ -38,10 +38,10 @@ const EVENT_DEFINITION = `
38
38
  int32_optional_value: ?Int32,
39
39
  int32_optional_both?: ?Int32,
40
40
 
41
- enum_required: ('small' | 'large'),
42
- enum_optional_key?: ('small' | 'large'),
43
- enum_optional_value: ?('small' | 'large'),
44
- enum_optional_both?: ?('small' | 'large'),
41
+ union_required: ('small' | 'large'),
42
+ union_optional_key?: ('small' | 'large'),
43
+ union_optional_value: ?('small' | 'large'),
44
+ union_optional_both?: ?('small' | 'large'),
45
45
 
46
46
  object_required: {
47
47
  boolean_required: boolean,
@@ -110,10 +110,10 @@ const EVENT_DEFINITION = `
110
110
  int32_array_optional_value: ?$ReadOnlyArray<Int32>,
111
111
  int32_array_optional_both?: ?Int32[],
112
112
 
113
- enum_array_required: $ReadOnlyArray<('small' | 'large')>,
114
- enum_array_optional_key?: ('small' | 'large')[],
115
- enum_array_optional_value: ?$ReadOnlyArray<('small' | 'large')>,
116
- enum_array_optional_both?: ?('small' | 'large')[],
113
+ union_array_required: $ReadOnlyArray<('small' | 'large')>,
114
+ union_array_optional_key?: ('small' | 'large')[],
115
+ union_array_optional_value: ?$ReadOnlyArray<('small' | 'large')>,
116
+ union_array_optional_both?: ?('small' | 'large')[],
117
117
 
118
118
  object_array_required: $ReadOnlyArray<{
119
119
  boolean_required: boolean,
@@ -38,10 +38,10 @@ const EVENT_DEFINITION = `
38
38
  int32_optional_value: ?Int32,
39
39
  int32_optional_both?: ?Int32,
40
40
 
41
- enum_required: ('small' | 'large'),
42
- enum_optional_key?: ('small' | 'large'),
43
- enum_optional_value: ?('small' | 'large'),
44
- enum_optional_both?: ?('small' | 'large'),
41
+ union_required: ('small' | 'large'),
42
+ union_optional_key?: ('small' | 'large'),
43
+ union_optional_value: ?('small' | 'large'),
44
+ union_optional_both?: ?('small' | 'large'),
45
45
 
46
46
  object_required: {
47
47
  boolean_required: boolean,
@@ -110,10 +110,10 @@ const EVENT_DEFINITION = `
110
110
  int32_array_optional_value: ?$ReadOnlyArray<Int32>,
111
111
  int32_array_optional_both?: ?Int32[],
112
112
 
113
- enum_array_required: $ReadOnlyArray<('small' | 'large')>,
114
- enum_array_optional_key?: ('small' | 'large')[],
115
- enum_array_optional_value: ?$ReadOnlyArray<('small' | 'large')>,
116
- enum_array_optional_both?: ?('small' | 'large')[],
113
+ union_array_required: $ReadOnlyArray<('small' | 'large')>,
114
+ union_array_optional_key?: ('small' | 'large')[],
115
+ union_array_optional_value: ?$ReadOnlyArray<('small' | 'large')>,
116
+ union_array_optional_both?: ?('small' | 'large')[],
117
117
 
118
118
  object_array_required: $ReadOnlyArray<{
119
119
  boolean_required: boolean,
@@ -104,10 +104,11 @@ function extractArrayElementType(typeAnnotation, name, parser) {
104
104
  };
105
105
  case 'UnionTypeAnnotation':
106
106
  return {
107
- type: 'StringEnumTypeAnnotation',
108
- options: typeAnnotation.types.map(option =>
109
- parser.getLiteralValue(option),
110
- ),
107
+ type: 'StringLiteralUnionTypeAnnotation',
108
+ types: typeAnnotation.types.map(option => ({
109
+ type: 'StringLiteralTypeAnnotation',
110
+ value: parser.getLiteralValue(option),
111
+ })),
111
112
  };
112
113
  case 'UnsafeMixed':
113
114
  return {
@@ -115,10 +115,11 @@ function extractArrayElementType(
115
115
  };
116
116
  case 'UnionTypeAnnotation':
117
117
  return {
118
- type: 'StringEnumTypeAnnotation',
119
- options: typeAnnotation.types.map(option =>
120
- parser.getLiteralValue(option),
121
- ),
118
+ type: 'StringLiteralUnionTypeAnnotation',
119
+ types: typeAnnotation.types.map(option => ({
120
+ type: 'StringLiteralTypeAnnotation',
121
+ value: parser.getLiteralValue(option),
122
+ })),
122
123
  };
123
124
  case 'UnsafeMixed':
124
125
  return {type: 'MixedTypeAnnotation'};
@@ -681,10 +681,11 @@ function emitUnionProp(name, optional, parser, typeAnnotation) {
681
681
  name,
682
682
  optional,
683
683
  typeAnnotation: {
684
- type: 'StringEnumTypeAnnotation',
685
- options: typeAnnotation.types.map(option =>
686
- parser.getLiteralValue(option),
687
- ),
684
+ type: 'StringLiteralUnionTypeAnnotation',
685
+ types: typeAnnotation.types.map(option => ({
686
+ type: 'StringLiteralTypeAnnotation',
687
+ value: parser.getLiteralValue(option),
688
+ })),
688
689
  },
689
690
  };
690
691
  }
@@ -752,10 +752,11 @@ function emitUnionProp(
752
752
  name,
753
753
  optional,
754
754
  typeAnnotation: {
755
- type: 'StringEnumTypeAnnotation',
756
- options: typeAnnotation.types.map(option =>
757
- parser.getLiteralValue(option),
758
- ),
755
+ type: 'StringLiteralUnionTypeAnnotation',
756
+ types: typeAnnotation.types.map(option => ({
757
+ type: 'StringLiteralTypeAnnotation',
758
+ value: parser.getLiteralValue(option),
759
+ })),
759
760
  },
760
761
  };
761
762
  }
@@ -38,10 +38,10 @@ const EVENT_DEFINITION = `
38
38
  int32_optional_value: Int32 | null | undefined;
39
39
  int32_optional_both?: Int32 | null | undefined;
40
40
 
41
- enum_required: 'small' | 'large';
42
- enum_optional_key?: 'small' | 'large';
43
- enum_optional_value: ('small' | 'large') | null | undefined;
44
- enum_optional_both?: ('small' | 'large') | null | undefined;
41
+ union_required: 'small' | 'large';
42
+ union_optional_key?: 'small' | 'large';
43
+ union_optional_value: ('small' | 'large') | null | undefined;
44
+ union_optional_both?: ('small' | 'large') | null | undefined;
45
45
 
46
46
  object_required: {
47
47
  boolean_required: boolean;
@@ -110,10 +110,10 @@ const EVENT_DEFINITION = `
110
110
  int32_array_optional_value: Int32[] | null | undefined;
111
111
  int32_array_optional_both?: Int32[] | null | undefined;
112
112
 
113
- enum_array_required: ('small' | 'large')[];
114
- enum_array_optional_key?: ('small' | 'large')[];
115
- enum_array_optional_value: ('small' | 'large')[] | null | undefined;
116
- enum_array_optional_both?: ('small' | 'large')[] | null | undefined;
113
+ union_array_required: ('small' | 'large')[];
114
+ union_array_optional_key?: ('small' | 'large')[];
115
+ union_array_optional_value: ('small' | 'large')[] | null | undefined;
116
+ union_array_optional_both?: ('small' | 'large')[] | null | undefined;
117
117
 
118
118
  object_array_required: {
119
119
  boolean_required: boolean;
@@ -38,10 +38,10 @@ const EVENT_DEFINITION = `
38
38
  int32_optional_value: Int32 | null | undefined;
39
39
  int32_optional_both?: Int32 | null | undefined;
40
40
 
41
- enum_required: 'small' | 'large';
42
- enum_optional_key?: 'small' | 'large';
43
- enum_optional_value: ('small' | 'large') | null | undefined;
44
- enum_optional_both?: ('small' | 'large') | null | undefined;
41
+ union_required: 'small' | 'large';
42
+ union_optional_key?: 'small' | 'large';
43
+ union_optional_value: ('small' | 'large') | null | undefined;
44
+ union_optional_both?: ('small' | 'large') | null | undefined;
45
45
 
46
46
  object_required: {
47
47
  boolean_required: boolean;
@@ -110,10 +110,10 @@ const EVENT_DEFINITION = `
110
110
  int32_array_optional_value: Int32[] | null | undefined;
111
111
  int32_array_optional_both?: Int32[] | null | undefined;
112
112
 
113
- enum_array_required: ('small' | 'large')[];
114
- enum_array_optional_key?: ('small' | 'large')[];
115
- enum_array_optional_value: ('small' | 'large')[] | null | undefined;
116
- enum_array_optional_both?: ('small' | 'large')[] | null | undefined;
113
+ union_array_required: ('small' | 'large')[];
114
+ union_array_optional_key?: ('small' | 'large')[];
115
+ union_array_optional_value: ('small' | 'large')[] | null | undefined;
116
+ union_array_optional_both?: ('small' | 'large')[] | null | undefined;
117
117
 
118
118
  object_array_required: {
119
119
  boolean_required: boolean;
@@ -114,10 +114,11 @@ function extractArrayElementType(typeAnnotation, name, parser) {
114
114
  };
115
115
  case 'TSUnionType':
116
116
  return {
117
- type: 'StringEnumTypeAnnotation',
118
- options: typeAnnotation.types.map(option =>
119
- parser.getLiteralValue(option),
120
- ),
117
+ type: 'StringLiteralUnionTypeAnnotation',
118
+ types: typeAnnotation.types.map(option => ({
119
+ type: 'StringLiteralTypeAnnotation',
120
+ value: parser.getLiteralValue(option),
121
+ })),
121
122
  };
122
123
  case 'TSTypeLiteral':
123
124
  return {
@@ -126,10 +126,11 @@ function extractArrayElementType(
126
126
  };
127
127
  case 'TSUnionType':
128
128
  return {
129
- type: 'StringEnumTypeAnnotation',
130
- options: typeAnnotation.types.map(option =>
131
- parser.getLiteralValue(option),
132
- ),
129
+ type: 'StringLiteralUnionTypeAnnotation',
130
+ types: typeAnnotation.types.map(option => ({
131
+ type: 'StringLiteralTypeAnnotation',
132
+ value: parser.getLiteralValue(option),
133
+ })),
133
134
  };
134
135
  case 'TSTypeLiteral':
135
136
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/codegen",
3
- "version": "0.78.0-nightly-20250102-93117ea1b",
3
+ "version": "0.78.0-nightly-20250104-a6e6f5e86",
4
4
  "description": "Code generation tools for React Native",
5
5
  "license": "MIT",
6
6
  "repository": {