@@ -170,22 +170,9 @@ module.exports = function propTypesInstructions(context, components, utils) {
170
170
/** @type {UnionTypeDefinition } */
171
171
const unionTypeDefinition = {
172
172
type : 'union' ,
173
- children : [ ]
173
+ children : annotation . types . map ( type => buildTypeAnnotationDeclarationTypes ( type , parentName , seen ) )
174
174
} ;
175
- for ( let i = 0 , j = annotation . types . length ; i < j ; i ++ ) {
176
- const type = buildTypeAnnotationDeclarationTypes ( annotation . types [ i ] , parentName , seen ) ;
177
- // keep only complex type
178
- if ( type . type ) {
179
- if ( type . children === true ) {
180
- // every child is accepted for one type, abort type analysis
181
- unionTypeDefinition . children = true ;
182
- return unionTypeDefinition ;
183
- }
184
- }
185
-
186
- /** @type {UnionTypeDefinitionChildren } */ ( unionTypeDefinition . children ) . push ( type ) ;
187
- }
188
- if ( /** @type {UnionTypeDefinitionChildren } */ ( unionTypeDefinition . children ) . length === 0 ) {
175
+ if ( unionTypeDefinition . children . length === 0 ) {
189
176
// no complex type found, simply accept everything
190
177
return { } ;
191
178
}
@@ -419,34 +406,14 @@ module.exports = function propTypesInstructions(context, components, utils) {
419
406
/** @type {UnionTypeDefinition } */
420
407
const unionTypeDefinition = {
421
408
type : 'union' ,
422
- children : [ ]
409
+ children : argument . elements . map ( element => buildReactDeclarationTypes ( element , parentName ) )
423
410
} ;
424
- for ( let i = 0 , j = argument . elements . length ; i < j ; i ++ ) {
425
- const type = buildReactDeclarationTypes ( argument . elements [ i ] , parentName ) ;
426
- // keep only complex type
427
- if ( type . type ) {
428
- if ( type . children === true ) {
429
- // every child is accepted for one type, abort type analysis
430
- unionTypeDefinition . children = true ;
431
- return unionTypeDefinition ;
432
- }
433
- }
434
-
435
- /** @type {UnionTypeDefinitionChildren } */ ( unionTypeDefinition . children ) . push ( type ) ;
436
- }
437
- if ( /** @type {UnionTypeDefinitionChildren } */ ( unionTypeDefinition . children ) . length === 0 ) {
411
+ if ( unionTypeDefinition . children . length === 0 ) {
438
412
// no complex type found, simply accept everything
439
413
return { } ;
440
414
}
441
415
return unionTypeDefinition ;
442
416
}
443
- case 'instanceOf' :
444
- return {
445
- type : 'instance' ,
446
- // Accept all children because we can't know what type they are
447
- children : true
448
- } ;
449
- case 'oneOf' :
450
417
default :
451
418
return { } ;
452
419
}
0 commit comments