File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
packages/react-docgen/src/utils Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import type {
12
12
FlowType ,
13
13
InterfaceDeclaration ,
14
14
InterfaceExtends ,
15
+ Node ,
15
16
TSExpressionWithTypeArguments ,
16
17
TSInterfaceDeclaration ,
17
18
TSType ,
@@ -41,6 +42,17 @@ function getStatelessPropsPath(
41
42
return value . get ( 'params' ) [ 0 ] ;
42
43
}
43
44
45
+ function getForwardRefGenericsType ( componentDefinition : NodePath ) {
46
+ const typeParameters = componentDefinition . get (
47
+ 'typeParameters' ,
48
+ ) as NodePath < Node > ;
49
+ if ( typeParameters && typeParameters . hasNode ( ) ) {
50
+ const params = typeParameters . get ( 'params' ) as NodePath < Node > [ ] ;
51
+ return params [ 1 ] ?? null ;
52
+ }
53
+ return null ;
54
+ }
55
+
44
56
function findAssignedVariableType (
45
57
componentDefinition : NodePath ,
46
58
) : NodePath | null {
@@ -106,6 +118,11 @@ export default (componentDefinition: NodePath): NodePath[] => {
106
118
}
107
119
}
108
120
} else {
121
+ const typeAnnotation = getForwardRefGenericsType ( componentDefinition ) ;
122
+ if ( typeAnnotation ) {
123
+ typePaths . push ( typeAnnotation ) ;
124
+ }
125
+
109
126
const propsParam = getStatelessPropsPath ( componentDefinition ) ;
110
127
111
128
if ( propsParam ) {
You can’t perform that action at this time.
0 commit comments