@react-native/codegen 0.73.0-nightly-20230731-b0a8d45e2 → 0.73.0-nightly-20230807-2bf59c764

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.
@@ -84,9 +84,7 @@ class UnsupportedTypeAnnotationParserError extends ParserError {
84
84
  class UnsupportedGenericParserError extends ParserError {
85
85
  // +genericName: string;
86
86
  constructor(nativeModuleName, genericTypeAnnotation, parser) {
87
- const genericName = parser.nameForGenericTypeAnnotation(
88
- genericTypeAnnotation,
89
- );
87
+ const genericName = parser.getTypeAnnotationName(genericTypeAnnotation);
90
88
  super(
91
89
  nativeModuleName,
92
90
  genericTypeAnnotation,
@@ -99,9 +97,7 @@ class UnsupportedGenericParserError extends ParserError {
99
97
 
100
98
  class MissingTypeParameterGenericParserError extends ParserError {
101
99
  constructor(nativeModuleName, genericTypeAnnotation, parser) {
102
- const genericName = parser.nameForGenericTypeAnnotation(
103
- genericTypeAnnotation,
104
- );
100
+ const genericName = parser.getTypeAnnotationName(genericTypeAnnotation);
105
101
  super(
106
102
  nativeModuleName,
107
103
  genericTypeAnnotation,
@@ -111,9 +107,7 @@ class MissingTypeParameterGenericParserError extends ParserError {
111
107
  }
112
108
  class MoreThanOneTypeParameterGenericParserError extends ParserError {
113
109
  constructor(nativeModuleName, genericTypeAnnotation, parser) {
114
- const genericName = parser.nameForGenericTypeAnnotation(
115
- genericTypeAnnotation,
116
- );
110
+ const genericName = parser.getTypeAnnotationName(genericTypeAnnotation);
117
111
  super(
118
112
  nativeModuleName,
119
113
  genericTypeAnnotation,
@@ -117,9 +117,7 @@ class UnsupportedGenericParserError extends ParserError {
117
117
  genericTypeAnnotation: $FlowFixMe,
118
118
  parser: Parser,
119
119
  ) {
120
- const genericName = parser.nameForGenericTypeAnnotation(
121
- genericTypeAnnotation,
122
- );
120
+ const genericName = parser.getTypeAnnotationName(genericTypeAnnotation);
123
121
  super(
124
122
  nativeModuleName,
125
123
  genericTypeAnnotation,
@@ -136,9 +134,7 @@ class MissingTypeParameterGenericParserError extends ParserError {
136
134
  genericTypeAnnotation: $FlowFixMe,
137
135
  parser: Parser,
138
136
  ) {
139
- const genericName = parser.nameForGenericTypeAnnotation(
140
- genericTypeAnnotation,
141
- );
137
+ const genericName = parser.getTypeAnnotationName(genericTypeAnnotation);
142
138
 
143
139
  super(
144
140
  nativeModuleName,
@@ -154,9 +150,7 @@ class MoreThanOneTypeParameterGenericParserError extends ParserError {
154
150
  genericTypeAnnotation: $FlowFixMe,
155
151
  parser: Parser,
156
152
  ) {
157
- const genericName = parser.nameForGenericTypeAnnotation(
158
- genericTypeAnnotation,
159
- );
153
+ const genericName = parser.getTypeAnnotationName(genericTypeAnnotation);
160
154
 
161
155
  super(
162
156
  nativeModuleName,
@@ -30,7 +30,7 @@ function getTypeAnnotationForArray(
30
30
  }
31
31
  if (
32
32
  extractedTypeAnnotation.type === 'GenericTypeAnnotation' &&
33
- extractedTypeAnnotation.id.name === 'WithDefault'
33
+ parser.getTypeAnnotationName(extractedTypeAnnotation) === 'WithDefault'
34
34
  ) {
35
35
  throw new Error(
36
36
  'Nested defaults such as "$ReadOnlyArray<WithDefault<boolean, false>>" are not supported, please declare defaults at the top level of value definitions as in "WithDefault<$ReadOnlyArray<boolean>, false>"',
@@ -75,7 +75,7 @@ function getTypeAnnotationForArray(
75
75
  }
76
76
  const type =
77
77
  extractedTypeAnnotation.type === 'GenericTypeAnnotation'
78
- ? extractedTypeAnnotation.id.name
78
+ ? parser.getTypeAnnotationName(extractedTypeAnnotation)
79
79
  : extractedTypeAnnotation.type;
80
80
  switch (type) {
81
81
  case 'ImageSource':
@@ -160,7 +160,6 @@ function getTypeAnnotationForArray(
160
160
  );
161
161
  }
162
162
  default:
163
- type;
164
163
  throw new Error(`Unknown property type for "${name}": ${type}`);
165
164
  }
166
165
  }
@@ -203,7 +202,7 @@ function getTypeAnnotation(
203
202
  const typeAnnotation = getValueFromTypes(annotation, types);
204
203
  if (
205
204
  typeAnnotation.type === 'GenericTypeAnnotation' &&
206
- typeAnnotation.id.name === '$ReadOnlyArray'
205
+ parser.getTypeAnnotationName(typeAnnotation) === '$ReadOnlyArray'
207
206
  ) {
208
207
  return {
209
208
  type: 'ArrayTypeAnnotation',
@@ -219,7 +218,7 @@ function getTypeAnnotation(
219
218
  }
220
219
  if (
221
220
  typeAnnotation.type === 'GenericTypeAnnotation' &&
222
- typeAnnotation.id.name === '$ReadOnly'
221
+ parser.getTypeAnnotationName(typeAnnotation) === '$ReadOnly'
223
222
  ) {
224
223
  return {
225
224
  type: 'ObjectTypeAnnotation',
@@ -234,7 +233,7 @@ function getTypeAnnotation(
234
233
  }
235
234
  const type =
236
235
  typeAnnotation.type === 'GenericTypeAnnotation'
237
- ? typeAnnotation.id.name
236
+ ? parser.getTypeAnnotationName(typeAnnotation)
238
237
  : typeAnnotation.type;
239
238
  switch (type) {
240
239
  case 'ImageSource':
@@ -361,7 +360,6 @@ function getTypeAnnotation(
361
360
  type: 'MixedTypeAnnotation',
362
361
  };
363
362
  default:
364
- type;
365
363
  throw new Error(
366
364
  `Unknown property type for "${name}": "${type}" in the State`,
367
365
  );
@@ -32,7 +32,7 @@ function getTypeAnnotationForArray<+T>(
32
32
 
33
33
  if (
34
34
  extractedTypeAnnotation.type === 'GenericTypeAnnotation' &&
35
- extractedTypeAnnotation.id.name === 'WithDefault'
35
+ parser.getTypeAnnotationName(extractedTypeAnnotation) === 'WithDefault'
36
36
  ) {
37
37
  throw new Error(
38
38
  'Nested defaults such as "$ReadOnlyArray<WithDefault<boolean, false>>" are not supported, please declare defaults at the top level of value definitions as in "WithDefault<$ReadOnlyArray<boolean>, false>"',
@@ -82,7 +82,7 @@ function getTypeAnnotationForArray<+T>(
82
82
 
83
83
  const type =
84
84
  extractedTypeAnnotation.type === 'GenericTypeAnnotation'
85
- ? extractedTypeAnnotation.id.name
85
+ ? parser.getTypeAnnotationName(extractedTypeAnnotation)
86
86
  : extractedTypeAnnotation.type;
87
87
 
88
88
  switch (type) {
@@ -170,7 +170,6 @@ function getTypeAnnotationForArray<+T>(
170
170
  );
171
171
  }
172
172
  default:
173
- (type: empty);
174
173
  throw new Error(`Unknown property type for "${name}": ${type}`);
175
174
  }
176
175
  }
@@ -220,7 +219,7 @@ function getTypeAnnotation<+T>(
220
219
 
221
220
  if (
222
221
  typeAnnotation.type === 'GenericTypeAnnotation' &&
223
- typeAnnotation.id.name === '$ReadOnlyArray'
222
+ parser.getTypeAnnotationName(typeAnnotation) === '$ReadOnlyArray'
224
223
  ) {
225
224
  return {
226
225
  type: 'ArrayTypeAnnotation',
@@ -237,7 +236,7 @@ function getTypeAnnotation<+T>(
237
236
 
238
237
  if (
239
238
  typeAnnotation.type === 'GenericTypeAnnotation' &&
240
- typeAnnotation.id.name === '$ReadOnly'
239
+ parser.getTypeAnnotationName(typeAnnotation) === '$ReadOnly'
241
240
  ) {
242
241
  return {
243
242
  type: 'ObjectTypeAnnotation',
@@ -253,7 +252,7 @@ function getTypeAnnotation<+T>(
253
252
 
254
253
  const type =
255
254
  typeAnnotation.type === 'GenericTypeAnnotation'
256
- ? typeAnnotation.id.name
255
+ ? parser.getTypeAnnotationName(typeAnnotation)
257
256
  : typeAnnotation.type;
258
257
 
259
258
  switch (type) {
@@ -379,7 +378,6 @@ function getTypeAnnotation<+T>(
379
378
  type: 'MixedTypeAnnotation',
380
379
  };
381
380
  default:
382
- (type: empty);
383
381
  throw new Error(
384
382
  `Unknown property type for "${name}": "${type}" in the State`,
385
383
  );
@@ -16,7 +16,8 @@ const _require = require('../../error-utils'),
16
16
  throwIfArgumentPropsAreNull = _require.throwIfArgumentPropsAreNull;
17
17
  const _require2 = require('../../parsers-commons'),
18
18
  getEventArgument = _require2.getEventArgument,
19
- buildPropertiesForEvent = _require2.buildPropertiesForEvent;
19
+ buildPropertiesForEvent = _require2.buildPropertiesForEvent,
20
+ handleEventHandler = _require2.handleEventHandler;
20
21
  const _require3 = require('../../parsers-primitives'),
21
22
  emitBoolProp = _require3.emitBoolProp,
22
23
  emitDoubleProp = _require3.emitDoubleProp,
@@ -24,7 +25,8 @@ const _require3 = require('../../parsers-primitives'),
24
25
  emitMixedProp = _require3.emitMixedProp,
25
26
  emitStringProp = _require3.emitStringProp,
26
27
  emitInt32Prop = _require3.emitInt32Prop,
27
- emitObjectProp = _require3.emitObjectProp;
28
+ emitObjectProp = _require3.emitObjectProp,
29
+ emitUnionProp = _require3.emitUnionProp;
28
30
  function getPropertyType(
29
31
  /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
30
32
  * LTI update could not be added via codemod */
@@ -33,7 +35,7 @@ function getPropertyType(
33
35
  typeAnnotation,
34
36
  parser,
35
37
  ) {
36
- const type = parser.extractTypeFromTypeAnnotation(typeAnnotation);
38
+ const type = extractTypeFromTypeAnnotation(typeAnnotation, parser);
37
39
  switch (type) {
38
40
  case 'BooleanTypeAnnotation':
39
41
  return emitBoolProp(name, optional);
@@ -61,16 +63,7 @@ function getPropertyType(
61
63
  extractArrayElementType,
62
64
  );
63
65
  case 'UnionTypeAnnotation':
64
- return {
65
- name,
66
- optional,
67
- typeAnnotation: {
68
- type: 'StringEnumTypeAnnotation',
69
- options: typeAnnotation.types.map(option =>
70
- parser.getLiteralValue(option),
71
- ),
72
- },
73
- };
66
+ return emitUnionProp(name, optional, parser, typeAnnotation);
74
67
  case 'UnsafeMixed':
75
68
  return emitMixedProp(name, optional);
76
69
  case 'ArrayTypeAnnotation':
@@ -85,7 +78,7 @@ function getPropertyType(
85
78
  }
86
79
  }
87
80
  function extractArrayElementType(typeAnnotation, name, parser) {
88
- const type = parser.extractTypeFromTypeAnnotation(typeAnnotation);
81
+ const type = extractTypeFromTypeAnnotation(typeAnnotation, parser);
89
82
  switch (type) {
90
83
  case 'BooleanTypeAnnotation':
91
84
  return {
@@ -161,6 +154,11 @@ function extractArrayElementType(typeAnnotation, name, parser) {
161
154
  function prettify(jsonObject) {
162
155
  return JSON.stringify(jsonObject, null, 2);
163
156
  }
157
+ function extractTypeFromTypeAnnotation(typeAnnotation, parser) {
158
+ return typeAnnotation.type === 'GenericTypeAnnotation'
159
+ ? parser.getTypeAnnotationName(typeAnnotation)
160
+ : typeAnnotation.type;
161
+ }
164
162
  function findEventArgumentsAndType(
165
163
  parser,
166
164
  typeAnnotation,
@@ -169,7 +167,7 @@ function findEventArgumentsAndType(
169
167
  paperName,
170
168
  ) {
171
169
  throwIfEventHasNoName(typeAnnotation, parser);
172
- const name = typeAnnotation.id.name;
170
+ const name = parser.getTypeAnnotationName(typeAnnotation);
173
171
  if (name === '$ReadOnly') {
174
172
  return {
175
173
  argumentProps: typeAnnotation.typeParameters.params[0].properties,
@@ -177,25 +175,12 @@ function findEventArgumentsAndType(
177
175
  bubblingType,
178
176
  };
179
177
  } else if (name === 'BubblingEventHandler' || name === 'DirectEventHandler') {
180
- const eventType = name === 'BubblingEventHandler' ? 'bubble' : 'direct';
181
- const paperTopLevelNameDeprecated =
182
- parser.getPaperTopLevelNameDeprecated(typeAnnotation);
183
- if (
184
- typeAnnotation.typeParameters.params[0].type ===
185
- parser.nullLiteralTypeAnnotation
186
- ) {
187
- return {
188
- argumentProps: [],
189
- bubblingType: eventType,
190
- paperTopLevelNameDeprecated,
191
- };
192
- }
193
- return findEventArgumentsAndType(
178
+ return handleEventHandler(
179
+ name,
180
+ typeAnnotation,
194
181
  parser,
195
- typeAnnotation.typeParameters.params[0],
196
182
  types,
197
- eventType,
198
- paperTopLevelNameDeprecated,
183
+ findEventArgumentsAndType,
199
184
  );
200
185
  } else if (types[name]) {
201
186
  return findEventArgumentsAndType(
@@ -223,8 +208,8 @@ function buildEventSchema(types, property, parser) {
223
208
  : property.value;
224
209
  if (
225
210
  typeAnnotation.type !== 'GenericTypeAnnotation' ||
226
- (typeAnnotation.id.name !== 'BubblingEventHandler' &&
227
- typeAnnotation.id.name !== 'DirectEventHandler')
211
+ (parser.getTypeAnnotationName(typeAnnotation) !== 'BubblingEventHandler' &&
212
+ parser.getTypeAnnotationName(typeAnnotation) !== 'DirectEventHandler')
228
213
  ) {
229
214
  return null;
230
215
  }
@@ -16,6 +16,7 @@ import type {
16
16
  EventTypeAnnotation,
17
17
  } from '../../../CodegenSchema.js';
18
18
  import type {Parser} from '../../parser';
19
+ import type {EventArgumentReturnType} from '../../parsers-commons';
19
20
 
20
21
  const {
21
22
  throwIfEventHasNoName,
@@ -25,6 +26,7 @@ const {
25
26
  const {
26
27
  getEventArgument,
27
28
  buildPropertiesForEvent,
29
+ handleEventHandler,
28
30
  } = require('../../parsers-commons');
29
31
  const {
30
32
  emitBoolProp,
@@ -34,6 +36,7 @@ const {
34
36
  emitStringProp,
35
37
  emitInt32Prop,
36
38
  emitObjectProp,
39
+ emitUnionProp,
37
40
  } = require('../../parsers-primitives');
38
41
 
39
42
  function getPropertyType(
@@ -44,7 +47,7 @@ function getPropertyType(
44
47
  typeAnnotation: $FlowFixMe,
45
48
  parser: Parser,
46
49
  ): NamedShape<EventTypeAnnotation> {
47
- const type = parser.extractTypeFromTypeAnnotation(typeAnnotation);
50
+ const type = extractTypeFromTypeAnnotation(typeAnnotation, parser);
48
51
 
49
52
  switch (type) {
50
53
  case 'BooleanTypeAnnotation':
@@ -73,16 +76,7 @@ function getPropertyType(
73
76
  extractArrayElementType,
74
77
  );
75
78
  case 'UnionTypeAnnotation':
76
- return {
77
- name,
78
- optional,
79
- typeAnnotation: {
80
- type: 'StringEnumTypeAnnotation',
81
- options: typeAnnotation.types.map(option =>
82
- parser.getLiteralValue(option),
83
- ),
84
- },
85
- };
79
+ return emitUnionProp(name, optional, parser, typeAnnotation);
86
80
  case 'UnsafeMixed':
87
81
  return emitMixedProp(name, optional);
88
82
  case 'ArrayTypeAnnotation':
@@ -102,7 +96,7 @@ function extractArrayElementType(
102
96
  name: string,
103
97
  parser: Parser,
104
98
  ): EventTypeAnnotation {
105
- const type = parser.extractTypeFromTypeAnnotation(typeAnnotation);
99
+ const type = extractTypeFromTypeAnnotation(typeAnnotation, parser);
106
100
 
107
101
  switch (type) {
108
102
  case 'BooleanTypeAnnotation':
@@ -171,19 +165,24 @@ function prettify(jsonObject: $FlowFixMe): string {
171
165
  return JSON.stringify(jsonObject, null, 2);
172
166
  }
173
167
 
168
+ function extractTypeFromTypeAnnotation(
169
+ typeAnnotation: $FlowFixMe,
170
+ parser: Parser,
171
+ ): string {
172
+ return typeAnnotation.type === 'GenericTypeAnnotation'
173
+ ? parser.getTypeAnnotationName(typeAnnotation)
174
+ : typeAnnotation.type;
175
+ }
176
+
174
177
  function findEventArgumentsAndType(
175
178
  parser: Parser,
176
179
  typeAnnotation: $FlowFixMe,
177
180
  types: TypeMap,
178
181
  bubblingType: void | 'direct' | 'bubble',
179
182
  paperName: ?$FlowFixMe,
180
- ): {
181
- argumentProps: $FlowFixMe,
182
- bubblingType: ?('direct' | 'bubble'),
183
- paperTopLevelNameDeprecated: ?$FlowFixMe,
184
- } {
183
+ ): EventArgumentReturnType {
185
184
  throwIfEventHasNoName(typeAnnotation, parser);
186
- const name = typeAnnotation.id.name;
185
+ const name = parser.getTypeAnnotationName(typeAnnotation);
187
186
  if (name === '$ReadOnly') {
188
187
  return {
189
188
  argumentProps: typeAnnotation.typeParameters.params[0].properties,
@@ -191,25 +190,12 @@ function findEventArgumentsAndType(
191
190
  bubblingType,
192
191
  };
193
192
  } else if (name === 'BubblingEventHandler' || name === 'DirectEventHandler') {
194
- const eventType = name === 'BubblingEventHandler' ? 'bubble' : 'direct';
195
- const paperTopLevelNameDeprecated =
196
- parser.getPaperTopLevelNameDeprecated(typeAnnotation);
197
- if (
198
- typeAnnotation.typeParameters.params[0].type ===
199
- parser.nullLiteralTypeAnnotation
200
- ) {
201
- return {
202
- argumentProps: [],
203
- bubblingType: eventType,
204
- paperTopLevelNameDeprecated,
205
- };
206
- }
207
- return findEventArgumentsAndType(
193
+ return handleEventHandler(
194
+ name,
195
+ typeAnnotation,
208
196
  parser,
209
- typeAnnotation.typeParameters.params[0],
210
197
  types,
211
- eventType,
212
- paperTopLevelNameDeprecated,
198
+ findEventArgumentsAndType,
213
199
  );
214
200
  } else if (types[name]) {
215
201
  return findEventArgumentsAndType(
@@ -244,8 +230,8 @@ function buildEventSchema(
244
230
 
245
231
  if (
246
232
  typeAnnotation.type !== 'GenericTypeAnnotation' ||
247
- (typeAnnotation.id.name !== 'BubblingEventHandler' &&
248
- typeAnnotation.id.name !== 'DirectEventHandler')
233
+ (parser.getTypeAnnotationName(typeAnnotation) !== 'BubblingEventHandler' &&
234
+ parser.getTypeAnnotationName(typeAnnotation) !== 'DirectEventHandler')
249
235
  ) {
250
236
  return null;
251
237
  }
@@ -122,7 +122,7 @@ function translateTypeAnnotation(
122
122
  typeResolutionStatus = _resolveTypeAnnotatio.typeResolutionStatus;
123
123
  switch (typeAnnotation.type) {
124
124
  case 'GenericTypeAnnotation': {
125
- switch (typeAnnotation.id.name) {
125
+ switch (parser.getTypeAnnotationName(typeAnnotation)) {
126
126
  case 'RootTag': {
127
127
  return emitRootTag(nullable);
128
128
  }
@@ -64,7 +64,7 @@ function translateTypeAnnotation(
64
64
 
65
65
  switch (typeAnnotation.type) {
66
66
  case 'GenericTypeAnnotation': {
67
- switch (typeAnnotation.id.name) {
67
+ switch (parser.getTypeAnnotationName(typeAnnotation)) {
68
68
  case 'RootTag': {
69
69
  return emitRootTag(nullable);
70
70
  }
@@ -101,7 +101,7 @@ class FlowParser {
101
101
  language() {
102
102
  return 'Flow';
103
103
  }
104
- nameForGenericTypeAnnotation(typeAnnotation) {
104
+ getTypeAnnotationName(typeAnnotation) {
105
105
  var _typeAnnotation$id;
106
106
  return typeAnnotation === null || typeAnnotation === void 0
107
107
  ? void 0
@@ -372,7 +372,7 @@ class FlowParser {
372
372
  if (node.type !== 'GenericTypeAnnotation') {
373
373
  break;
374
374
  }
375
- const typeAnnotationName = this.nameForGenericTypeAnnotation(node);
375
+ const typeAnnotationName = this.getTypeAnnotationName(node);
376
376
  const resolvedTypeAnnotation = types[typeAnnotationName];
377
377
  if (resolvedTypeAnnotation == null) {
378
378
  break;
@@ -99,7 +99,7 @@ class FlowParser implements Parser {
99
99
  return 'Flow';
100
100
  }
101
101
 
102
- nameForGenericTypeAnnotation(typeAnnotation: $FlowFixMe): string {
102
+ getTypeAnnotationName(typeAnnotation: $FlowFixMe): string {
103
103
  return typeAnnotation?.id?.name;
104
104
  }
105
105
 
@@ -421,7 +421,7 @@ class FlowParser implements Parser {
421
421
  break;
422
422
  }
423
423
 
424
- const typeAnnotationName = this.nameForGenericTypeAnnotation(node);
424
+ const typeAnnotationName = this.getTypeAnnotationName(node);
425
425
  const resolvedTypeAnnotation = types[typeAnnotationName];
426
426
  if (resolvedTypeAnnotation == null) {
427
427
  break;
@@ -127,11 +127,11 @@ export interface Parser {
127
127
  */
128
128
  language(): ParserType;
129
129
  /**
130
- * Given a type annotation for a generic type, it returns the type name.
130
+ * Given a type annotation, it returns the type name.
131
131
  * @parameter typeAnnotation: the annotation for a type in the AST.
132
132
  * @returns: the name of the type.
133
133
  */
134
- nameForGenericTypeAnnotation(typeAnnotation: $FlowFixMe): string;
134
+ getTypeAnnotationName(typeAnnotation: $FlowFixMe): string;
135
135
  /**
136
136
  * Given a type arguments, it returns a boolean specifying if the Module is Invalid.
137
137
  * @parameter typeArguments: the type arguments.
@@ -102,8 +102,14 @@ export class MockedParser {
102
102
  language() {
103
103
  return 'Flow';
104
104
  }
105
- nameForGenericTypeAnnotation(typeAnnotation) {
106
- return typeAnnotation.id.name;
105
+ getTypeAnnotationName(typeAnnotation) {
106
+ var _typeAnnotation$id;
107
+ return typeAnnotation === null || typeAnnotation === void 0
108
+ ? void 0
109
+ : (_typeAnnotation$id = typeAnnotation.id) === null ||
110
+ _typeAnnotation$id === void 0
111
+ ? void 0
112
+ : _typeAnnotation$id.name;
107
113
  }
108
114
  checkIfInvalidModule(typeArguments) {
109
115
  return false;
@@ -96,8 +96,8 @@ export class MockedParser implements Parser {
96
96
  return 'Flow';
97
97
  }
98
98
 
99
- nameForGenericTypeAnnotation(typeAnnotation: $FlowFixMe): string {
100
- return typeAnnotation.id.name;
99
+ getTypeAnnotationName(typeAnnotation: $FlowFixMe): string {
100
+ return typeAnnotation?.id?.name;
101
101
  }
102
102
 
103
103
  checkIfInvalidModule(typeArguments: $FlowFixMe): boolean {
@@ -811,7 +811,7 @@ function getCommandTypeNameAndOptionsExpression(namedExport, parser) {
811
811
  );
812
812
  }
813
813
  return {
814
- commandTypeName: parser.nameForGenericTypeAnnotation(typeArgumentParam),
814
+ commandTypeName: parser.getTypeAnnotationName(typeArgumentParam),
815
815
  commandOptionsExpression: callExpression.arguments[0],
816
816
  };
817
817
  }
@@ -944,7 +944,7 @@ function getTypeResolutionStatus(type, typeAnnotation, parser) {
944
944
  return {
945
945
  successful: true,
946
946
  type,
947
- name: parser.nameForGenericTypeAnnotation(typeAnnotation),
947
+ name: parser.getTypeAnnotationName(typeAnnotation),
948
948
  };
949
949
  }
950
950
  function handleGenericTypeAnnotation(
@@ -1007,6 +1007,34 @@ function verifyPropNotAlreadyDefined(props, needleProp) {
1007
1007
  throw new Error(`A prop was already defined with the name ${propName}`);
1008
1008
  }
1009
1009
  }
1010
+ function handleEventHandler(
1011
+ name,
1012
+ typeAnnotation,
1013
+ parser,
1014
+ types,
1015
+ findEventArgumentsAndType,
1016
+ ) {
1017
+ const eventType = name === 'BubblingEventHandler' ? 'bubble' : 'direct';
1018
+ const paperTopLevelNameDeprecated =
1019
+ parser.getPaperTopLevelNameDeprecated(typeAnnotation);
1020
+ switch (typeAnnotation.typeParameters.params[0].type) {
1021
+ case parser.nullLiteralTypeAnnotation:
1022
+ case parser.undefinedLiteralTypeAnnotation:
1023
+ return {
1024
+ argumentProps: [],
1025
+ bubblingType: eventType,
1026
+ paperTopLevelNameDeprecated,
1027
+ };
1028
+ default:
1029
+ return findEventArgumentsAndType(
1030
+ parser,
1031
+ typeAnnotation.typeParameters.params[0],
1032
+ types,
1033
+ eventType,
1034
+ paperTopLevelNameDeprecated,
1035
+ );
1036
+ }
1037
+ }
1010
1038
  module.exports = {
1011
1039
  wrapModuleSchema,
1012
1040
  unwrapNullable,
@@ -1035,4 +1063,5 @@ module.exports = {
1035
1063
  getTypeResolutionStatus,
1036
1064
  buildPropertiesForEvent,
1037
1065
  verifyPropNotAlreadyDefined,
1066
+ handleEventHandler,
1038
1067
  };
@@ -87,6 +87,12 @@ type ExtendedPropResult = {
87
87
  knownTypeName: 'ReactNativeCoreViewProps',
88
88
  } | null;
89
89
 
90
+ export type EventArgumentReturnType = {
91
+ argumentProps: ?$ReadOnlyArray<$FlowFixMe>,
92
+ paperTopLevelNameDeprecated: ?$FlowFixMe,
93
+ bubblingType: ?'direct' | 'bubble',
94
+ };
95
+
90
96
  function wrapModuleSchema(
91
97
  nativeModuleSchema: NativeModuleSchema,
92
98
  hasteModuleName: string,
@@ -818,7 +824,7 @@ function getCommandTypeNameAndOptionsExpression(
818
824
  }
819
825
 
820
826
  return {
821
- commandTypeName: parser.nameForGenericTypeAnnotation(typeArgumentParam),
827
+ commandTypeName: parser.getTypeAnnotationName(typeArgumentParam),
822
828
  commandOptionsExpression: callExpression.arguments[0],
823
829
  };
824
830
  }
@@ -998,7 +1004,7 @@ function getTypeResolutionStatus(
998
1004
  return {
999
1005
  successful: true,
1000
1006
  type,
1001
- name: parser.nameForGenericTypeAnnotation(typeAnnotation),
1007
+ name: parser.getTypeAnnotationName(typeAnnotation),
1002
1008
  };
1003
1009
  }
1004
1010
 
@@ -1083,6 +1089,42 @@ function verifyPropNotAlreadyDefined(
1083
1089
  }
1084
1090
  }
1085
1091
 
1092
+ function handleEventHandler(
1093
+ name: 'BubblingEventHandler' | 'DirectEventHandler',
1094
+ typeAnnotation: $FlowFixMe,
1095
+ parser: Parser,
1096
+ types: TypeDeclarationMap,
1097
+ findEventArgumentsAndType: (
1098
+ parser: Parser,
1099
+ typeAnnotation: $FlowFixMe,
1100
+ types: TypeDeclarationMap,
1101
+ bubblingType: void | 'direct' | 'bubble',
1102
+ paperName: ?$FlowFixMe,
1103
+ ) => EventArgumentReturnType,
1104
+ ): EventArgumentReturnType {
1105
+ const eventType = name === 'BubblingEventHandler' ? 'bubble' : 'direct';
1106
+ const paperTopLevelNameDeprecated =
1107
+ parser.getPaperTopLevelNameDeprecated(typeAnnotation);
1108
+
1109
+ switch (typeAnnotation.typeParameters.params[0].type) {
1110
+ case parser.nullLiteralTypeAnnotation:
1111
+ case parser.undefinedLiteralTypeAnnotation:
1112
+ return {
1113
+ argumentProps: [],
1114
+ bubblingType: eventType,
1115
+ paperTopLevelNameDeprecated,
1116
+ };
1117
+ default:
1118
+ return findEventArgumentsAndType(
1119
+ parser,
1120
+ typeAnnotation.typeParameters.params[0],
1121
+ types,
1122
+ eventType,
1123
+ paperTopLevelNameDeprecated,
1124
+ );
1125
+ }
1126
+ }
1127
+
1086
1128
  module.exports = {
1087
1129
  wrapModuleSchema,
1088
1130
  unwrapNullable,
@@ -1111,4 +1153,5 @@ module.exports = {
1111
1153
  getTypeResolutionStatus,
1112
1154
  buildPropertiesForEvent,
1113
1155
  verifyPropNotAlreadyDefined,
1156
+ handleEventHandler,
1114
1157
  };
@@ -567,7 +567,7 @@ function emitCommonTypes(
567
567
  return simpleEmitter(nullable);
568
568
  }
569
569
  const genericTypeAnnotationName =
570
- parser.nameForGenericTypeAnnotation(typeAnnotation);
570
+ parser.getTypeAnnotationName(typeAnnotation);
571
571
  const emitter = typeMap[genericTypeAnnotationName];
572
572
  if (!emitter) {
573
573
  return null;
@@ -615,6 +615,18 @@ function emitObjectProp(
615
615
  typeAnnotation: extractArrayElementType(typeAnnotation, name, parser),
616
616
  };
617
617
  }
618
+ function emitUnionProp(name, optional, parser, typeAnnotation) {
619
+ return {
620
+ name,
621
+ optional,
622
+ typeAnnotation: {
623
+ type: 'StringEnumTypeAnnotation',
624
+ options: typeAnnotation.types.map(option =>
625
+ parser.getLiteralValue(option),
626
+ ),
627
+ },
628
+ };
629
+ }
618
630
  module.exports = {
619
631
  emitArrayType,
620
632
  emitBoolean,
@@ -646,4 +658,5 @@ module.exports = {
646
658
  translateArrayTypeAnnotation,
647
659
  Visitor,
648
660
  emitObjectProp,
661
+ emitUnionProp,
649
662
  };
@@ -611,7 +611,7 @@ function emitCommonTypes(
611
611
  }
612
612
 
613
613
  const genericTypeAnnotationName =
614
- parser.nameForGenericTypeAnnotation(typeAnnotation);
614
+ parser.getTypeAnnotationName(typeAnnotation);
615
615
 
616
616
  const emitter = typeMap[genericTypeAnnotationName];
617
617
  if (!emitter) {
@@ -675,6 +675,24 @@ function emitObjectProp(
675
675
  };
676
676
  }
677
677
 
678
+ function emitUnionProp(
679
+ name: string,
680
+ optional: boolean,
681
+ parser: Parser,
682
+ typeAnnotation: $FlowFixMe,
683
+ ): NamedShape<EventTypeAnnotation> {
684
+ return {
685
+ name,
686
+ optional,
687
+ typeAnnotation: {
688
+ type: 'StringEnumTypeAnnotation',
689
+ options: typeAnnotation.types.map(option =>
690
+ parser.getLiteralValue(option),
691
+ ),
692
+ },
693
+ };
694
+ }
695
+
678
696
  module.exports = {
679
697
  emitArrayType,
680
698
  emitBoolean,
@@ -706,4 +724,5 @@ module.exports = {
706
724
  translateArrayTypeAnnotation,
707
725
  Visitor,
708
726
  emitObjectProp,
727
+ emitUnionProp,
709
728
  };
@@ -120,8 +120,8 @@ function detectArrayType(
120
120
  // Covers: Array<T> and ReadonlyArray<T>
121
121
  if (
122
122
  typeAnnotation.type === 'TSTypeReference' &&
123
- (typeAnnotation.typeName.name === 'ReadonlyArray' ||
124
- typeAnnotation.typeName.name === 'Array')
123
+ (parser.getTypeAnnotationName(typeAnnotation) === 'ReadonlyArray' ||
124
+ parser.getTypeAnnotationName(typeAnnotation) === 'Array')
125
125
  ) {
126
126
  return {
127
127
  type: 'ArrayTypeAnnotation',
@@ -360,7 +360,7 @@ function getTypeAnnotation(
360
360
  const type =
361
361
  typeAnnotation.type === 'TSTypeReference' ||
362
362
  typeAnnotation.type === 'TSTypeAliasDeclaration'
363
- ? typeAnnotation.typeName.name
363
+ ? parser.getTypeAnnotationName(typeAnnotation)
364
364
  : typeAnnotation.type;
365
365
  const common = getCommonTypeAnnotation(
366
366
  name,
@@ -394,7 +394,6 @@ function getTypeAnnotation(
394
394
  `Cannot use "${type}" type annotation for "${name}": must use a specific function type like BubblingEventHandler, or DirectEventHandler`,
395
395
  );
396
396
  default:
397
- type;
398
397
  throw new Error(`Unknown prop type for "${name}": "${type}"`);
399
398
  }
400
399
  }
@@ -121,8 +121,8 @@ function detectArrayType<T>(
121
121
  // Covers: Array<T> and ReadonlyArray<T>
122
122
  if (
123
123
  typeAnnotation.type === 'TSTypeReference' &&
124
- (typeAnnotation.typeName.name === 'ReadonlyArray' ||
125
- typeAnnotation.typeName.name === 'Array')
124
+ (parser.getTypeAnnotationName(typeAnnotation) === 'ReadonlyArray' ||
125
+ parser.getTypeAnnotationName(typeAnnotation) === 'Array')
126
126
  ) {
127
127
  return {
128
128
  type: 'ArrayTypeAnnotation',
@@ -378,7 +378,7 @@ function getTypeAnnotation<T>(
378
378
  const type =
379
379
  typeAnnotation.type === 'TSTypeReference' ||
380
380
  typeAnnotation.type === 'TSTypeAliasDeclaration'
381
- ? typeAnnotation.typeName.name
381
+ ? parser.getTypeAnnotationName(typeAnnotation)
382
382
  : typeAnnotation.type;
383
383
 
384
384
  const common = getCommonTypeAnnotation(
@@ -414,7 +414,6 @@ function getTypeAnnotation<T>(
414
414
  `Cannot use "${type}" type annotation for "${name}": must use a specific function type like BubblingEventHandler, or DirectEventHandler`,
415
415
  );
416
416
  default:
417
- (type: empty);
418
417
  throw new Error(`Unknown prop type for "${name}": "${type}"`);
419
418
  }
420
419
  }
@@ -20,7 +20,8 @@ const _require3 = require('../../error-utils'),
20
20
  throwIfArgumentPropsAreNull = _require3.throwIfArgumentPropsAreNull;
21
21
  const _require4 = require('../../parsers-commons'),
22
22
  getEventArgument = _require4.getEventArgument,
23
- buildPropertiesForEvent = _require4.buildPropertiesForEvent;
23
+ buildPropertiesForEvent = _require4.buildPropertiesForEvent,
24
+ handleEventHandler = _require4.handleEventHandler;
24
25
  const _require5 = require('../../parsers-primitives'),
25
26
  emitBoolProp = _require5.emitBoolProp,
26
27
  emitDoubleProp = _require5.emitDoubleProp,
@@ -28,7 +29,8 @@ const _require5 = require('../../parsers-primitives'),
28
29
  emitMixedProp = _require5.emitMixedProp,
29
30
  emitStringProp = _require5.emitStringProp,
30
31
  emitInt32Prop = _require5.emitInt32Prop,
31
- emitObjectProp = _require5.emitObjectProp;
32
+ emitObjectProp = _require5.emitObjectProp,
33
+ emitUnionProp = _require5.emitUnionProp;
32
34
  function getPropertyType(
33
35
  /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
34
36
  * LTI update could not be added via codemod */
@@ -42,7 +44,10 @@ function getPropertyType(
42
44
  const topLevelType = parseTopLevelType(annotation);
43
45
  const typeAnnotation = topLevelType.type;
44
46
  const optional = optionalProperty || topLevelType.optional;
45
- const type = parser.extractTypeFromTypeAnnotation(typeAnnotation);
47
+ const type =
48
+ typeAnnotation.type === 'TSTypeReference'
49
+ ? parser.getTypeAnnotationName(typeAnnotation)
50
+ : typeAnnotation.type;
46
51
  switch (type) {
47
52
  case 'TSBooleanKeyword':
48
53
  return emitBoolProp(name, optional);
@@ -63,16 +68,7 @@ function getPropertyType(
63
68
  extractArrayElementType,
64
69
  );
65
70
  case 'TSUnionType':
66
- return {
67
- name,
68
- optional,
69
- typeAnnotation: {
70
- type: 'StringEnumTypeAnnotation',
71
- options: typeAnnotation.types.map(option =>
72
- parser.getLiteralValue(option),
73
- ),
74
- },
75
- };
71
+ return emitUnionProp(name, optional, parser, typeAnnotation);
76
72
  case 'UnsafeMixed':
77
73
  return emitMixedProp(name, optional);
78
74
  case 'TSArrayType':
@@ -86,7 +82,7 @@ function getPropertyType(
86
82
  }
87
83
  }
88
84
  function extractArrayElementType(typeAnnotation, name, parser) {
89
- const type = parser.extractTypeFromTypeAnnotation(typeAnnotation);
85
+ const type = extractTypeFromTypeAnnotation(typeAnnotation, parser);
90
86
  switch (type) {
91
87
  case 'TSParenthesizedType':
92
88
  return extractArrayElementType(
@@ -150,6 +146,11 @@ function extractArrayElementType(typeAnnotation, name, parser) {
150
146
  );
151
147
  }
152
148
  }
149
+ function extractTypeFromTypeAnnotation(typeAnnotation, parser) {
150
+ return typeAnnotation.type === 'TSTypeReference'
151
+ ? parser.getTypeAnnotationName(typeAnnotation)
152
+ : typeAnnotation.type;
153
+ }
153
154
  function findEventArgumentsAndType(
154
155
  parser,
155
156
  typeAnnotation,
@@ -172,7 +173,7 @@ function findEventArgumentsAndType(
172
173
  };
173
174
  }
174
175
  throwIfEventHasNoName(typeAnnotation, parser);
175
- const name = typeAnnotation.typeName.name;
176
+ const name = parser.getTypeAnnotationName(typeAnnotation);
176
177
  if (name === 'Readonly') {
177
178
  return findEventArgumentsAndType(
178
179
  parser,
@@ -182,26 +183,13 @@ function findEventArgumentsAndType(
182
183
  paperName,
183
184
  );
184
185
  } else if (name === 'BubblingEventHandler' || name === 'DirectEventHandler') {
185
- const eventType = name === 'BubblingEventHandler' ? 'bubble' : 'direct';
186
- const paperTopLevelNameDeprecated =
187
- parser.getPaperTopLevelNameDeprecated(typeAnnotation);
188
- switch (typeAnnotation.typeParameters.params[0].type) {
189
- case parser.nullLiteralTypeAnnotation:
190
- case parser.undefinedLiteralTypeAnnotation:
191
- return {
192
- argumentProps: [],
193
- bubblingType: eventType,
194
- paperTopLevelNameDeprecated,
195
- };
196
- default:
197
- return findEventArgumentsAndType(
198
- parser,
199
- typeAnnotation.typeParameters.params[0],
200
- types,
201
- eventType,
202
- paperTopLevelNameDeprecated,
203
- );
204
- }
186
+ return handleEventHandler(
187
+ name,
188
+ typeAnnotation,
189
+ parser,
190
+ types,
191
+ findEventArgumentsAndType,
192
+ );
205
193
  } else if (types[name]) {
206
194
  let elementType = types[name];
207
195
  if (elementType.type === 'TSTypeAliasDeclaration') {
@@ -27,6 +27,7 @@ const {
27
27
  const {
28
28
  getEventArgument,
29
29
  buildPropertiesForEvent,
30
+ handleEventHandler,
30
31
  } = require('../../parsers-commons');
31
32
  const {
32
33
  emitBoolProp,
@@ -36,6 +37,7 @@ const {
36
37
  emitStringProp,
37
38
  emitInt32Prop,
38
39
  emitObjectProp,
40
+ emitUnionProp,
39
41
  } = require('../../parsers-primitives');
40
42
  function getPropertyType(
41
43
  /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
@@ -50,7 +52,10 @@ function getPropertyType(
50
52
  const topLevelType = parseTopLevelType(annotation);
51
53
  const typeAnnotation = topLevelType.type;
52
54
  const optional = optionalProperty || topLevelType.optional;
53
- const type = parser.extractTypeFromTypeAnnotation(typeAnnotation);
55
+ const type =
56
+ typeAnnotation.type === 'TSTypeReference'
57
+ ? parser.getTypeAnnotationName(typeAnnotation)
58
+ : typeAnnotation.type;
54
59
 
55
60
  switch (type) {
56
61
  case 'TSBooleanKeyword':
@@ -72,16 +77,7 @@ function getPropertyType(
72
77
  extractArrayElementType,
73
78
  );
74
79
  case 'TSUnionType':
75
- return {
76
- name,
77
- optional,
78
- typeAnnotation: {
79
- type: 'StringEnumTypeAnnotation',
80
- options: typeAnnotation.types.map(option =>
81
- parser.getLiteralValue(option),
82
- ),
83
- },
84
- };
80
+ return emitUnionProp(name, optional, parser, typeAnnotation);
85
81
  case 'UnsafeMixed':
86
82
  return emitMixedProp(name, optional);
87
83
  case 'TSArrayType':
@@ -100,7 +96,7 @@ function extractArrayElementType(
100
96
  name: string,
101
97
  parser: Parser,
102
98
  ): EventTypeAnnotation {
103
- const type = parser.extractTypeFromTypeAnnotation(typeAnnotation);
99
+ const type = extractTypeFromTypeAnnotation(typeAnnotation, parser);
104
100
 
105
101
  switch (type) {
106
102
  case 'TSParenthesizedType':
@@ -162,6 +158,15 @@ function extractArrayElementType(
162
158
  }
163
159
  }
164
160
 
161
+ function extractTypeFromTypeAnnotation(
162
+ typeAnnotation: $FlowFixMe,
163
+ parser: Parser,
164
+ ): string {
165
+ return typeAnnotation.type === 'TSTypeReference'
166
+ ? parser.getTypeAnnotationName(typeAnnotation)
167
+ : typeAnnotation.type;
168
+ }
169
+
165
170
  function findEventArgumentsAndType(
166
171
  parser: Parser,
167
172
  typeAnnotation: $FlowFixMe,
@@ -190,7 +195,7 @@ function findEventArgumentsAndType(
190
195
  }
191
196
 
192
197
  throwIfEventHasNoName(typeAnnotation, parser);
193
- const name = typeAnnotation.typeName.name;
198
+ const name = parser.getTypeAnnotationName(typeAnnotation);
194
199
  if (name === 'Readonly') {
195
200
  return findEventArgumentsAndType(
196
201
  parser,
@@ -200,27 +205,13 @@ function findEventArgumentsAndType(
200
205
  paperName,
201
206
  );
202
207
  } else if (name === 'BubblingEventHandler' || name === 'DirectEventHandler') {
203
- const eventType = name === 'BubblingEventHandler' ? 'bubble' : 'direct';
204
- const paperTopLevelNameDeprecated =
205
- parser.getPaperTopLevelNameDeprecated(typeAnnotation);
206
-
207
- switch (typeAnnotation.typeParameters.params[0].type) {
208
- case parser.nullLiteralTypeAnnotation:
209
- case parser.undefinedLiteralTypeAnnotation:
210
- return {
211
- argumentProps: [],
212
- bubblingType: eventType,
213
- paperTopLevelNameDeprecated,
214
- };
215
- default:
216
- return findEventArgumentsAndType(
217
- parser,
218
- typeAnnotation.typeParameters.params[0],
219
- types,
220
- eventType,
221
- paperTopLevelNameDeprecated,
222
- );
223
- }
208
+ return handleEventHandler(
209
+ name,
210
+ typeAnnotation,
211
+ parser,
212
+ types,
213
+ findEventArgumentsAndType,
214
+ );
224
215
  } else if (types[name]) {
225
216
  let elementType = types[name];
226
217
  if (elementType.type === 'TSTypeAliasDeclaration') {
@@ -218,7 +218,7 @@ function translateTypeAnnotation(
218
218
  }
219
219
  case 'TSTypeReference': {
220
220
  return translateTypeReferenceAnnotation(
221
- typeAnnotation.typeName.name,
221
+ parser.getTypeAnnotationName(typeAnnotation),
222
222
  nullable,
223
223
  typeAnnotation,
224
224
  hasteModuleName,
@@ -234,7 +234,7 @@ function translateTypeAnnotation(
234
234
  }
235
235
  case 'TSTypeReference': {
236
236
  return translateTypeReferenceAnnotation(
237
- typeAnnotation.typeName.name,
237
+ parser.getTypeAnnotationName(typeAnnotation),
238
238
  nullable,
239
239
  typeAnnotation,
240
240
  hasteModuleName,
@@ -101,7 +101,7 @@ class TypeScriptParser {
101
101
  language() {
102
102
  return 'TypeScript';
103
103
  }
104
- nameForGenericTypeAnnotation(typeAnnotation) {
104
+ getTypeAnnotationName(typeAnnotation) {
105
105
  var _typeAnnotation$typeN;
106
106
  return typeAnnotation === null || typeAnnotation === void 0
107
107
  ? void 0
@@ -391,7 +391,7 @@ class TypeScriptParser {
391
391
  if (node.type !== 'TSTypeReference') {
392
392
  break;
393
393
  }
394
- const typeAnnotationName = this.nameForGenericTypeAnnotation(node);
394
+ const typeAnnotationName = this.getTypeAnnotationName(node);
395
395
  const resolvedTypeAnnotation = types[typeAnnotationName];
396
396
  if (resolvedTypeAnnotation == null) {
397
397
  break;
@@ -422,7 +422,7 @@ class TypeScriptParser {
422
422
  return false;
423
423
  }
424
424
  const eventNames = new Set(['BubblingEventHandler', 'DirectEventHandler']);
425
- return eventNames.has(typeAnnotation.typeName.name);
425
+ return eventNames.has(this.getTypeAnnotationName(typeAnnotation));
426
426
  }
427
427
  isProp(name, typeAnnotation) {
428
428
  if (typeAnnotation.type !== 'TSTypeReference') {
@@ -431,7 +431,7 @@ class TypeScriptParser {
431
431
  const isStyle =
432
432
  name === 'style' &&
433
433
  typeAnnotation.type === 'GenericTypeAnnotation' &&
434
- typeAnnotation.typeName.name === 'ViewStyleProp';
434
+ this.getTypeAnnotationName(typeAnnotation) === 'ViewStyleProp';
435
435
  return !isStyle;
436
436
  }
437
437
  getProps(typeDefinition, types) {
@@ -94,7 +94,7 @@ class TypeScriptParser implements Parser {
94
94
  return 'TypeScript';
95
95
  }
96
96
 
97
- nameForGenericTypeAnnotation(typeAnnotation: $FlowFixMe): string {
97
+ getTypeAnnotationName(typeAnnotation: $FlowFixMe): string {
98
98
  return typeAnnotation?.typeName?.name;
99
99
  }
100
100
 
@@ -413,7 +413,7 @@ class TypeScriptParser implements Parser {
413
413
  break;
414
414
  }
415
415
 
416
- const typeAnnotationName = this.nameForGenericTypeAnnotation(node);
416
+ const typeAnnotationName = this.getTypeAnnotationName(node);
417
417
  const resolvedTypeAnnotation = types[typeAnnotationName];
418
418
  if (resolvedTypeAnnotation == null) {
419
419
  break;
@@ -447,7 +447,7 @@ class TypeScriptParser implements Parser {
447
447
  return false;
448
448
  }
449
449
  const eventNames = new Set(['BubblingEventHandler', 'DirectEventHandler']);
450
- return eventNames.has(typeAnnotation.typeName.name);
450
+ return eventNames.has(this.getTypeAnnotationName(typeAnnotation));
451
451
  }
452
452
 
453
453
  isProp(name: string, typeAnnotation: $FlowFixMe): boolean {
@@ -457,7 +457,7 @@ class TypeScriptParser implements Parser {
457
457
  const isStyle =
458
458
  name === 'style' &&
459
459
  typeAnnotation.type === 'GenericTypeAnnotation' &&
460
- typeAnnotation.typeName.name === 'ViewStyleProp';
460
+ this.getTypeAnnotationName(typeAnnotation) === 'ViewStyleProp';
461
461
  return !isStyle;
462
462
  }
463
463
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/codegen",
3
- "version": "0.73.0-nightly-20230731-b0a8d45e2",
3
+ "version": "0.73.0-nightly-20230807-2bf59c764",
4
4
  "description": "Code generation tools for React Native",
5
5
  "license": "MIT",
6
6
  "repository": {