File tree Expand file tree Collapse file tree
packages/react-docgen/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -203,6 +203,7 @@ export default class DocumentationBuilder {
203203 const obj : Documentation = { } ;
204204
205205 for ( const [ key , value ] of this . #data) {
206+ // @ts -expect-error The types for Documentation do not allow to be extended atm
206207 obj [ key ] = value ;
207208 }
208209
Original file line number Diff line number Diff line change @@ -28,7 +28,15 @@ export function isSupportedUtilityType(
2828 */
2929export function unwrapUtilityType ( path : NodePath ) : NodePath {
3030 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 ;
3240 }
3341
3442 return path ;
Original file line number Diff line number Diff line change @@ -170,7 +170,8 @@ function getPropTypeShapish(
170170 }
171171
172172 if ( argumentPath . isObjectExpression ( ) ) {
173- let value : Record < string , PropTypeDescriptor > | string = { } ;
173+ const value : Record < string , PropTypeDescriptor > = { } ;
174+ let rawValue : string | undefined ;
174175
175176 argumentPath . get ( 'properties' ) . forEach ( ( propertyPath ) => {
176177 // We only handle ObjectProperty as there is nothing to handle for
@@ -186,7 +187,7 @@ function getPropTypeShapish(
186187 // This indicates we have a cyclic reference in the shape
187188 // In this case we simply print the argument to shape and bail
188189 if ( argument && isCyclicReference ( argument , argumentPath ) ) {
189- value = printValue ( argument ) ;
190+ rawValue = printValue ( argument ) ;
190191
191192 return ;
192193 }
@@ -202,7 +203,7 @@ function getPropTypeShapish(
202203 }
203204 } ) ;
204205
205- type . value = value ;
206+ type . value = rawValue ?? value ;
206207 }
207208
208209 return type ;
You can’t perform that action at this time.
0 commit comments