@@ -170,22 +170,9 @@ module.exports = function propTypesInstructions(context, components, utils) {
170170 /** @type {UnionTypeDefinition } */
171171 const unionTypeDefinition = {
172172 type : 'union' ,
173- children : [ ]
173+ children : annotation . types . map ( type => buildTypeAnnotationDeclarationTypes ( type , parentName , seen ) )
174174 } ;
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 ) {
189176 // no complex type found, simply accept everything
190177 return { } ;
191178 }
@@ -419,34 +406,14 @@ module.exports = function propTypesInstructions(context, components, utils) {
419406 /** @type {UnionTypeDefinition } */
420407 const unionTypeDefinition = {
421408 type : 'union' ,
422- children : [ ]
409+ children : argument . elements . map ( element => buildReactDeclarationTypes ( element , parentName ) )
423410 } ;
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 ) {
438412 // no complex type found, simply accept everything
439413 return { } ;
440414 }
441415 return unionTypeDefinition ;
442416 }
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' :
450417 default :
451418 return { } ;
452419 }
0 commit comments