@@ -627,7 +627,7 @@ module.exports = function propTypesInstructions(context, components, utils) {
627
627
typeName = node . typeName . name ;
628
628
const leftMostName = getLeftMostTypeName ( node . typeName ) ;
629
629
const shouldTraverseTypeParams = genericReactTypesImport . has ( leftMostName ) ;
630
- const nodeTypeParams = node . typeParameters ;
630
+ const nodeTypeParams = node . typeArguments || node . typeParameters ;
631
631
if ( shouldTraverseTypeParams && nodeTypeParams && nodeTypeParams . length !== 0 ) {
632
632
// All react Generic types are derived from:
633
633
// type PropsWithChildren<P> = P & { children?: ReactNode | undefined }
@@ -728,7 +728,7 @@ module.exports = function propTypesInstructions(context, components, utils) {
728
728
729
729
convertReturnTypeToPropTypes ( node ) {
730
730
// ReturnType<T> should always have one parameter
731
- const nodeTypeParams = node . typeParameters ;
731
+ const nodeTypeParams = node . typeArguments || node . typeParameters ;
732
732
if ( nodeTypeParams ) {
733
733
if ( nodeTypeParams . params . length === 1 ) {
734
734
let returnType = nodeTypeParams . params [ 0 ] ;
@@ -763,7 +763,8 @@ module.exports = function propTypesInstructions(context, components, utils) {
763
763
case 'ObjectExpression' :
764
764
iterateProperties ( context , res . properties , ( key , value , propNode ) => {
765
765
if ( propNode && propNode . argument && propNode . argument . type === 'CallExpression' ) {
766
- const propNodeTypeParams = propNode . argument . typeParameters ;
766
+ const propNodeTypeParams = propNode . argument . typeArguments
767
+ || propNode . argument . typeParameters ;
767
768
if ( propNodeTypeParams ) {
768
769
this . visitTSNode ( propNodeTypeParams ) ;
769
770
} else {
@@ -785,8 +786,8 @@ module.exports = function propTypesInstructions(context, components, utils) {
785
786
} ) ;
786
787
break ;
787
788
case 'CallExpression' :
788
- if ( res . typeParameters ) {
789
- this . visitTSNode ( res . typeParameters ) ;
789
+ if ( res . typeArguments || res . typeParameters ) {
790
+ this . visitTSNode ( res . typeArguments || res . typeParameters ) ;
790
791
} else {
791
792
// Ignore this CallExpression return value since it doesn't have any typeParameters to let us know it's types.
792
793
this . shouldIgnorePropTypes = true ;
@@ -963,7 +964,7 @@ module.exports = function propTypesInstructions(context, components, utils) {
963
964
break ;
964
965
case 'GenericTypeAnnotation' :
965
966
if ( propTypes . id . name === '$ReadOnly' ) {
966
- const propTypeParams = propTypes . typeParameters ;
967
+ const propTypeParams = propTypes . typeArguments || propTypes . typeParameters ;
967
968
ignorePropsValidation = declarePropTypesForObjectTypeAnnotation (
968
969
propTypeParams . params [ 0 ] ,
969
970
declaredPropTypes
@@ -1004,8 +1005,10 @@ module.exports = function propTypesInstructions(context, components, utils) {
1004
1005
if (
1005
1006
node . parent
1006
1007
&& node . parent . callee
1007
- && node . parent . typeParameters
1008
- && node . parent . typeParameters . params
1008
+ && (
1009
+ ( node . parent . typeArguments && node . parent . typeArguments . params )
1010
+ || ( node . parent . typeParameters && node . parent . typeParameters . params )
1011
+ )
1009
1012
&& (
1010
1013
node . parent . callee . name === 'forwardRef' || (
1011
1014
node . parent . callee . object
@@ -1015,7 +1018,7 @@ module.exports = function propTypesInstructions(context, components, utils) {
1015
1018
)
1016
1019
)
1017
1020
) {
1018
- const propTypesParams = node . parent . typeParameters ;
1021
+ const propTypesParams = node . parent . typeArguments || node . parent . typeParameters ;
1019
1022
const declaredPropTypes = { } ;
1020
1023
const obj = new DeclarePropTypesForTSTypeAnnotation ( propTypesParams . params [ 1 ] , declaredPropTypes ) ;
1021
1024
components . set ( node , {
@@ -1063,7 +1066,7 @@ module.exports = function propTypesInstructions(context, components, utils) {
1063
1066
if (
1064
1067
annotation
1065
1068
&& annotation . type !== 'TSTypeReference'
1066
- && annotation . typeParameters == null
1069
+ && ( annotation . typeArguments == null || annotation . typeParameters == null )
1067
1070
) {
1068
1071
return ;
1069
1072
}
0 commit comments