@@ -755,28 +755,21 @@ module.exports = {
755755 * @returns {Boolean } True if propTypes should be ignored (e.g. when a type can't be resolved, when it is imported)
756756 */
757757 function declarePropTypesForIntersectionTypeAnnotation ( propTypes , declaredPropTypes ) {
758- return propTypes . types . reduce ( ( ignorePropsValidation , annotation ) => {
759- // If we already decided to skip props validation then we don't have to continue processing anything else
760- if ( ignorePropsValidation ) {
761- return ignorePropsValidation ;
758+ return propTypes . types . some ( annotation => {
759+ if ( annotation . type === 'ObjectTypeAnnotation' ) {
760+ return declarePropTypesForObjectTypeAnnotation ( annotation , declaredPropTypes ) ;
762761 }
763762
764- if ( annotation . type === 'ObjectTypeAnnotation' ) {
765- ignorePropsValidation = declarePropTypesForObjectTypeAnnotation ( annotation , declaredPropTypes ) ;
766- } else {
767- const typeNode = typeScope ( annotation . id . name ) ;
768-
769- if ( ! typeNode ) {
770- ignorePropsValidation = true ;
771- } else if ( typeNode . type === 'IntersectionTypeAnnotation' ) {
772- ignorePropsValidation = declarePropTypesForIntersectionTypeAnnotation ( typeNode , declaredPropTypes ) ;
773- } else {
774- ignorePropsValidation = declarePropTypesForObjectTypeAnnotation ( typeNode , declaredPropTypes ) ;
775- }
763+ const typeNode = typeScope ( annotation . id . name ) ;
764+
765+ if ( ! typeNode ) {
766+ return true ;
767+ } else if ( typeNode . type === 'IntersectionTypeAnnotation' ) {
768+ return declarePropTypesForIntersectionTypeAnnotation ( typeNode , declaredPropTypes ) ;
776769 }
777770
778- return ignorePropsValidation ;
779- } , false ) ;
771+ return declarePropTypesForObjectTypeAnnotation ( typeNode , declaredPropTypes ) ;
772+ } ) ;
780773 }
781774
782775 /**
0 commit comments