@@ -41,7 +41,8 @@ function isFunctionType(node) {
4141 */
4242function isSuperTypeParameterPropsDeclaration ( node ) {
4343 if ( node && ( node . type === 'ClassDeclaration' || node . type === 'ClassExpression' ) ) {
44- if ( node . superTypeParameters && node . superTypeParameters . params . length > 0 ) {
44+ const parameters = propsUtil . getSuperTypeArguments ( node ) ;
45+ if ( parameters && parameters . params . length > 0 ) {
4546 return true ;
4647 }
4748 }
@@ -1119,23 +1120,25 @@ module.exports = function propTypesInstructions(context, components, utils) {
11191120 }
11201121
11211122 /**
1122- * Resolve the type annotation for a given class declaration node with superTypeParameters .
1123+ * Resolve the type annotation for a given class declaration node.
11231124 *
11241125 * @param {ASTNode } node The annotation or a node containing the type annotation.
11251126 * @returns {ASTNode } The resolved type annotation for the node.
11261127 */
11271128 function resolveSuperParameterPropsType ( node ) {
11281129 let propsParameterPosition ;
1130+ const parameters = propsUtil . getSuperTypeArguments ( node ) ;
1131+
11291132 try {
11301133 // Flow <=0.52 had 3 required TypedParameters of which the second one is the Props.
11311134 // Flow >=0.53 has 2 optional TypedParameters of which the first one is the Props.
11321135 propsParameterPosition = testFlowVersion ( context , '>= 0.53.0' ) ? 0 : 1 ;
11331136 } catch ( e ) {
11341137 // In case there is no flow version defined, we can safely assume that when there are 3 Props we are dealing with version <= 0.52
1135- propsParameterPosition = node . superTypeParameters . params . length <= 2 ? 0 : 1 ;
1138+ propsParameterPosition = parameters . params . length <= 2 ? 0 : 1 ;
11361139 }
11371140
1138- let annotation = node . superTypeParameters . params [ propsParameterPosition ] ;
1141+ let annotation = parameters . params [ propsParameterPosition ] ;
11391142 while ( annotation && ( annotation . type === 'TypeAnnotation' || annotation . type === 'NullableTypeAnnotation' ) ) {
11401143 annotation = annotation . typeAnnotation ;
11411144 }
0 commit comments