Skip to content

Commit 138dec6

Browse files
committed
fix ts types
1 parent fbbd399 commit 138dec6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/react-docgen/src/utils/flowUtilityTypes.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,16 @@ export function isSupportedUtilityType(
2727
* $ReadOnly<T> => T
2828
*/
2929
export function unwrapUtilityType(path: NodePath): NodePath {
30-
while (isSupportedUtilityType(path)) {
31-
path = path.get('typeParameters').get('params')[0];
30+
let resultPath: NodePath = path;
31+
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;
3239
}
3340

34-
return path;
41+
return resultPath;
3542
}

0 commit comments

Comments
 (0)