We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fbbd399 commit 138dec6Copy full SHA for 138dec6
packages/react-docgen/src/utils/flowUtilityTypes.ts
@@ -27,9 +27,16 @@ export function isSupportedUtilityType(
27
* $ReadOnly<T> => T
28
*/
29
export function unwrapUtilityType(path: NodePath): NodePath {
30
- while (isSupportedUtilityType(path)) {
31
- path = path.get('typeParameters').get('params')[0];
+ let resultPath: NodePath = path;
+ while (isSupportedUtilityType(resultPath)) {
32
+ const typeParameters = resultPath.get('typeParameters');
33
+ if (!typeParameters.hasNode()) break;
34
+
35
+ const firstParam = typeParameters.get('params')[0];
36
+ if (!firstParam) break;
37
38
+ resultPath = firstParam;
39
}
40
- return path;
41
+ return resultPath;
42
0 commit comments