File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed
packages/react-docgen/src Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,7 @@ export default class DocumentationBuilder {
203
203
const obj : Documentation = { } ;
204
204
205
205
for ( const [ key , value ] of this . #data) {
206
+ // @ts -expect-error The types for Documentation do not allow to be extended atm
206
207
obj [ key ] = value ;
207
208
}
208
209
Original file line number Diff line number Diff line change @@ -28,7 +28,15 @@ export function isSupportedUtilityType(
28
28
*/
29
29
export function unwrapUtilityType ( path : NodePath ) : NodePath {
30
30
while ( isSupportedUtilityType ( path ) ) {
31
- path = path . get ( 'typeParameters' ) . get ( 'params' ) [ 0 ] ;
31
+ const typeParameters = path . get ( 'typeParameters' ) ;
32
+
33
+ if ( ! typeParameters . hasNode ( ) ) break ;
34
+
35
+ const param = typeParameters . get ( 'params' ) [ 0 ] ;
36
+
37
+ if ( ! param ) break ;
38
+
39
+ path = param ;
32
40
}
33
41
34
42
return path ;
Original file line number Diff line number Diff line change @@ -170,7 +170,8 @@ function getPropTypeShapish(
170
170
}
171
171
172
172
if ( argumentPath . isObjectExpression ( ) ) {
173
- let value : Record < string , PropTypeDescriptor > | string = { } ;
173
+ const value : Record < string , PropTypeDescriptor > = { } ;
174
+ let rawValue : string | undefined ;
174
175
175
176
argumentPath . get ( 'properties' ) . forEach ( ( propertyPath ) => {
176
177
// We only handle ObjectProperty as there is nothing to handle for
@@ -186,7 +187,7 @@ function getPropTypeShapish(
186
187
// This indicates we have a cyclic reference in the shape
187
188
// In this case we simply print the argument to shape and bail
188
189
if ( argument && isCyclicReference ( argument , argumentPath ) ) {
189
- value = printValue ( argument ) ;
190
+ rawValue = printValue ( argument ) ;
190
191
191
192
return ;
192
193
}
@@ -202,7 +203,7 @@ function getPropTypeShapish(
202
203
}
203
204
} ) ;
204
205
205
- type . value = value ;
206
+ type . value = rawValue ?? value ;
206
207
}
207
208
208
209
return type ;
You can’t perform that action at this time.
0 commit comments