@react-native/codegen 0.84.0-nightly-20251218-c7f433a41 → 0.84.0-nightly-20251220-00eba5504

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.
@@ -73,11 +73,12 @@ function buildCommandSchema(property, types, parser) {
73
73
  break;
74
74
  case 'Array':
75
75
  case '$ReadOnlyArray':
76
+ case 'ReadonlyArray':
76
77
  /* $FlowFixMe[invalid-compare] Error discovered during Constant
77
78
  * Condition roll out. See https://fburl.com/workplace/4oq3zi07. */
78
79
  if (!paramValue.type === 'GenericTypeAnnotation') {
79
80
  throw new Error(
80
- 'Array and $ReadOnlyArray are GenericTypeAnnotation for array',
81
+ 'Array, $ReadOnlyArray and ReadonlyArray are GenericTypeAnnotation for array',
81
82
  );
82
83
  }
83
84
  returnType = {
@@ -105,11 +105,12 @@ function buildCommandSchema(
105
105
  break;
106
106
  case 'Array':
107
107
  case '$ReadOnlyArray':
108
+ case 'ReadonlyArray':
108
109
  /* $FlowFixMe[invalid-compare] Error discovered during Constant
109
110
  * Condition roll out. See https://fburl.com/workplace/4oq3zi07. */
110
111
  if (!paramValue.type === 'GenericTypeAnnotation') {
111
112
  throw new Error(
112
- 'Array and $ReadOnlyArray are GenericTypeAnnotation for array',
113
+ 'Array, $ReadOnlyArray and ReadonlyArray are GenericTypeAnnotation for array',
113
114
  );
114
115
  }
115
116
  returnType = {
@@ -39,7 +39,10 @@ function getTypeAnnotationForArray(
39
39
  if (extractedTypeAnnotation.type === 'GenericTypeAnnotation') {
40
40
  // Resolve the type alias if it's not defined inline
41
41
  const objectType = getValueFromTypes(extractedTypeAnnotation, types);
42
- if (objectType.id.name === '$ReadOnly') {
42
+ if (
43
+ objectType.id.name === '$ReadOnly' ||
44
+ objectType.id.name === 'Readonly'
45
+ ) {
43
46
  return {
44
47
  type: 'ObjectTypeAnnotation',
45
48
  properties: flattenProperties(
@@ -51,7 +54,10 @@ function getTypeAnnotationForArray(
51
54
  .filter(Boolean),
52
55
  };
53
56
  }
54
- if (objectType.id.name === '$ReadOnlyArray') {
57
+ if (
58
+ objectType.id.name === '$ReadOnlyArray' ||
59
+ objectType.id.name === 'ReadonlyArray'
60
+ ) {
55
61
  // We need to go yet another level deeper to resolve
56
62
  // types that may be defined in a type alias
57
63
  const nestedObjectType = getValueFromTypes(
@@ -208,7 +214,8 @@ function getTypeAnnotation(
208
214
  const typeAnnotation = getValueFromTypes(annotation, types);
209
215
  if (
210
216
  typeAnnotation.type === 'GenericTypeAnnotation' &&
211
- parser.getTypeAnnotationName(typeAnnotation) === '$ReadOnlyArray'
217
+ (parser.getTypeAnnotationName(typeAnnotation) === '$ReadOnlyArray' ||
218
+ parser.getTypeAnnotationName(typeAnnotation) === 'ReadonlyArray')
212
219
  ) {
213
220
  return {
214
221
  type: 'ArrayTypeAnnotation',
@@ -224,7 +231,8 @@ function getTypeAnnotation(
224
231
  }
225
232
  if (
226
233
  typeAnnotation.type === 'GenericTypeAnnotation' &&
227
- parser.getTypeAnnotationName(typeAnnotation) === '$ReadOnly'
234
+ (parser.getTypeAnnotationName(typeAnnotation) === '$ReadOnly' ||
235
+ parser.getTypeAnnotationName(typeAnnotation) === 'Readonly')
228
236
  ) {
229
237
  return {
230
238
  type: 'ObjectTypeAnnotation',
@@ -45,7 +45,10 @@ function getTypeAnnotationForArray<+T>(
45
45
  // Resolve the type alias if it's not defined inline
46
46
  const objectType = getValueFromTypes(extractedTypeAnnotation, types);
47
47
 
48
- if (objectType.id.name === '$ReadOnly') {
48
+ if (
49
+ objectType.id.name === '$ReadOnly' ||
50
+ objectType.id.name === 'Readonly'
51
+ ) {
49
52
  return {
50
53
  type: 'ObjectTypeAnnotation',
51
54
  properties: flattenProperties(
@@ -58,7 +61,10 @@ function getTypeAnnotationForArray<+T>(
58
61
  };
59
62
  }
60
63
 
61
- if (objectType.id.name === '$ReadOnlyArray') {
64
+ if (
65
+ objectType.id.name === '$ReadOnlyArray' ||
66
+ objectType.id.name === 'ReadonlyArray'
67
+ ) {
62
68
  // We need to go yet another level deeper to resolve
63
69
  // types that may be defined in a type alias
64
70
  const nestedObjectType = getValueFromTypes(
@@ -226,7 +232,8 @@ function getTypeAnnotation<+T>(
226
232
 
227
233
  if (
228
234
  typeAnnotation.type === 'GenericTypeAnnotation' &&
229
- parser.getTypeAnnotationName(typeAnnotation) === '$ReadOnlyArray'
235
+ (parser.getTypeAnnotationName(typeAnnotation) === '$ReadOnlyArray' ||
236
+ parser.getTypeAnnotationName(typeAnnotation) === 'ReadonlyArray')
230
237
  ) {
231
238
  return {
232
239
  type: 'ArrayTypeAnnotation',
@@ -243,7 +250,8 @@ function getTypeAnnotation<+T>(
243
250
 
244
251
  if (
245
252
  typeAnnotation.type === 'GenericTypeAnnotation' &&
246
- parser.getTypeAnnotationName(typeAnnotation) === '$ReadOnly'
253
+ (parser.getTypeAnnotationName(typeAnnotation) === '$ReadOnly' ||
254
+ parser.getTypeAnnotationName(typeAnnotation) === 'Readonly')
247
255
  ) {
248
256
  return {
249
257
  type: 'ObjectTypeAnnotation',
@@ -52,6 +52,7 @@ function getPropertyType(
52
52
  case 'Float':
53
53
  return emitFloatProp(name, optional);
54
54
  case '$ReadOnly':
55
+ case 'Readonly':
55
56
  return getPropertyType(
56
57
  name,
57
58
  optional,
@@ -72,6 +73,7 @@ function getPropertyType(
72
73
  return emitMixedProp(name, optional);
73
74
  case 'ArrayTypeAnnotation':
74
75
  case '$ReadOnlyArray':
76
+ case 'ReadonlyArray':
75
77
  return {
76
78
  name,
77
79
  optional,
@@ -136,6 +138,7 @@ function extractArrayElementType(typeAnnotation, name, parser) {
136
138
  ),
137
139
  };
138
140
  case '$ReadOnlyArray':
141
+ case 'ReadonlyArray':
139
142
  const genericParams = typeAnnotation.typeParameters.params;
140
143
  if (genericParams.length !== 1) {
141
144
  throw new Error(
@@ -169,7 +172,7 @@ function findEventArgumentsAndType(
169
172
  ) {
170
173
  throwIfEventHasNoName(typeAnnotation, parser);
171
174
  const name = parser.getTypeAnnotationName(typeAnnotation);
172
- if (name === '$ReadOnly') {
175
+ if (name === '$ReadOnly' || name === 'Readonly') {
173
176
  return {
174
177
  argumentProps: typeAnnotation.typeParameters.params[0].properties,
175
178
  paperTopLevelNameDeprecated: paperName,
@@ -62,6 +62,7 @@ function getPropertyType(
62
62
  case 'Float':
63
63
  return emitFloatProp(name, optional);
64
64
  case '$ReadOnly':
65
+ case 'Readonly':
65
66
  return getPropertyType(
66
67
  name,
67
68
  optional,
@@ -82,6 +83,7 @@ function getPropertyType(
82
83
  return emitMixedProp(name, optional);
83
84
  case 'ArrayTypeAnnotation':
84
85
  case '$ReadOnlyArray':
86
+ case 'ReadonlyArray':
85
87
  return {
86
88
  name,
87
89
  optional,
@@ -142,6 +144,7 @@ function extractArrayElementType(
142
144
  ),
143
145
  };
144
146
  case '$ReadOnlyArray':
147
+ case 'ReadonlyArray':
145
148
  const genericParams = typeAnnotation.typeParameters.params;
146
149
  if (genericParams.length !== 1) {
147
150
  throw new Error(
@@ -185,7 +188,7 @@ function findEventArgumentsAndType(
185
188
  ): EventArgumentReturnType {
186
189
  throwIfEventHasNoName(typeAnnotation, parser);
187
190
  const name = parser.getTypeAnnotationName(typeAnnotation);
188
- if (name === '$ReadOnly') {
191
+ if (name === '$ReadOnly' || name === 'Readonly') {
189
192
  return {
190
193
  argumentProps: typeAnnotation.typeParameters.params[0].properties,
191
194
  paperTopLevelNameDeprecated: paperName,
@@ -87,7 +87,8 @@ function translateTypeAnnotation(
87
87
  );
88
88
  }
89
89
  case 'Array':
90
- case '$ReadOnlyArray': {
90
+ case '$ReadOnlyArray':
91
+ case 'ReadonlyArray': {
91
92
  return emitArrayType(
92
93
  hasteModuleName,
93
94
  typeAnnotation,
@@ -100,7 +101,8 @@ function translateTypeAnnotation(
100
101
  translateTypeAnnotation,
101
102
  );
102
103
  }
103
- case '$ReadOnly': {
104
+ case '$ReadOnly':
105
+ case 'Readonly': {
104
106
  assertGenericTypeAnnotationHasExactlyOneTypeParameter(
105
107
  hasteModuleName,
106
108
  typeAnnotation,
@@ -100,7 +100,8 @@ function translateTypeAnnotation(
100
100
  );
101
101
  }
102
102
  case 'Array':
103
- case '$ReadOnlyArray': {
103
+ case '$ReadOnlyArray':
104
+ case 'ReadonlyArray': {
104
105
  return emitArrayType(
105
106
  hasteModuleName,
106
107
  typeAnnotation,
@@ -113,7 +114,8 @@ function translateTypeAnnotation(
113
114
  translateTypeAnnotation,
114
115
  );
115
116
  }
116
- case '$ReadOnly': {
117
+ case '$ReadOnly':
118
+ case 'Readonly': {
117
119
  assertGenericTypeAnnotationHasExactlyOneTypeParameter(
118
120
  hasteModuleName,
119
121
  typeAnnotation,
@@ -536,6 +536,7 @@ function emitCommonTypes(
536
536
  StringTypeAnnotation: emitString,
537
537
  MixedTypeAnnotation: cxxOnly ? emitMixed : emitGenericObject,
538
538
  UnsafeMixed: cxxOnly ? emitMixed : emitGenericObject,
539
+ unknown: cxxOnly ? emitMixed : emitGenericObject,
539
540
  };
540
541
  const typeAnnotationName = parser.convertKeywordToTypeAnnotation(
541
542
  typeAnnotation.type,
@@ -664,6 +664,7 @@ function emitCommonTypes(
664
664
  StringTypeAnnotation: emitString,
665
665
  MixedTypeAnnotation: cxxOnly ? emitMixed : emitGenericObject,
666
666
  UnsafeMixed: cxxOnly ? emitMixed : emitGenericObject,
667
+ unknown: cxxOnly ? emitMixed : emitGenericObject,
667
668
  };
668
669
 
669
670
  const typeAnnotationName = parser.convertKeywordToTypeAnnotation(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/codegen",
3
- "version": "0.84.0-nightly-20251218-c7f433a41",
3
+ "version": "0.84.0-nightly-20251220-00eba5504",
4
4
  "description": "Code generation tools for React Native",
5
5
  "license": "MIT",
6
6
  "repository": {