@@ -710,6 +710,20 @@ module.exports = {
710710 } ) ;
711711 }
712712
713+ function declarePropTypesForObjectTypeAnnotation ( propTypes , declaredPropTypes ) {
714+ let ignorePropsValidation = false ;
715+
716+ iterateProperties ( propTypes . properties , ( key , value ) => {
717+ if ( ! value ) {
718+ ignorePropsValidation = true ;
719+ return ;
720+ }
721+ declaredPropTypes [ key ] = buildTypeAnnotationDeclarationTypes ( value ) ;
722+ } ) ;
723+
724+ return ignorePropsValidation ;
725+ }
726+
713727 /**
714728 * Marks all props found inside IntersectionTypeAnnotation as declared.
715729 * Since InterSectionTypeAnnotations can be nested, this handles recursively.
@@ -723,22 +737,26 @@ module.exports = {
723737 let ignorePropsValidation = false ;
724738
725739 propTypes . types . forEach ( annotation => {
726- const typeNode = typeScope ( annotation . id . name ) ;
727- if ( ! typeNode ) {
728- ignorePropsValidation = true ;
729- return ;
730- }
731-
732- if ( typeNode . type === 'IntersectionTypeAnnotation' ) {
733- ignorePropsValidation = declarePropTypesForIntersectionTypeAnnotation ( typeNode , declaredPropTypes ) ;
740+ if ( annotation . type === 'ObjectTypeAnnotation' ) {
741+ ignorePropsValidation = declarePropTypesForObjectTypeAnnotation ( annotation , declaredPropTypes ) ;
734742 } else {
735- iterateProperties ( typeNode . properties , ( key , value ) => {
736- if ( ! value ) {
737- ignorePropsValidation = true ;
738- return ;
739- }
740- declaredPropTypes [ key ] = buildTypeAnnotationDeclarationTypes ( value ) ;
741- } ) ;
743+ const typeNode = typeScope ( annotation . id . name ) ;
744+ if ( ! typeNode ) {
745+ ignorePropsValidation = true ;
746+ return ;
747+ }
748+
749+ if ( typeNode . type === 'IntersectionTypeAnnotation' ) {
750+ ignorePropsValidation = declarePropTypesForIntersectionTypeAnnotation ( typeNode , declaredPropTypes ) ;
751+ } else {
752+ iterateProperties ( typeNode . properties , ( key , value ) => {
753+ if ( ! value ) {
754+ ignorePropsValidation = true ;
755+ return ;
756+ }
757+ declaredPropTypes [ key ] = buildTypeAnnotationDeclarationTypes ( value ) ;
758+ } ) ;
759+ }
742760 }
743761 } ) ;
744762
@@ -761,13 +779,7 @@ module.exports = {
761779
762780 switch ( propTypes && propTypes . type ) {
763781 case 'ObjectTypeAnnotation' :
764- iterateProperties ( propTypes . properties , ( key , value ) => {
765- if ( ! value ) {
766- ignorePropsValidation = true ;
767- return ;
768- }
769- declaredPropTypes [ key ] = buildTypeAnnotationDeclarationTypes ( value ) ;
770- } ) ;
782+ ignorePropsValidation = declarePropTypesForObjectTypeAnnotation ( propTypes , declaredPropTypes ) ;
771783 break ;
772784 case 'ObjectExpression' :
773785 iterateProperties ( propTypes . properties , ( key , value ) => {
0 commit comments