Skip to content

Commit dc3acdf

Browse files
committed
refactor: extract ObjectMethod handling to a dedicated condition
1 parent ac37bf7 commit dc3acdf

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ function resolveName(path: NodePath): string | undefined {
4242
path.isArrowFunctionExpression() ||
4343
path.isTaggedTemplateExpression() ||
4444
path.isCallExpression() ||
45-
path.isObjectMethod() ||
4645
isReactForwardRefCall(path)
4746
) {
4847
let currentPath: NodePath = path;
@@ -64,6 +63,16 @@ function resolveName(path: NodePath): string | undefined {
6463
return;
6564
}
6665

66+
if (path.isObjectMethod()) {
67+
const key = path.get('key');
68+
69+
if (key.isIdentifier()) {
70+
return key.node.name;
71+
}
72+
73+
return;
74+
}
75+
6776
throw new TypeError(
6877
'Attempted to resolveName for an unsupported path. resolveName does not accept ' +
6978
path.node.type +

0 commit comments

Comments
 (0)