Skip to content

Commit 70b667f

Browse files
committed
fix: Ignore methods in Object.value() calls
# Conflicts: # src/utils/__tests__/__snapshots__/resolveObjectValuesToArray-test.ts.snap # src/utils/__tests__/resolveObjectValuesToArray-test.ts
1 parent 6ac7535 commit 70b667f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/utils/__tests__/resolveObjectValuesToArray-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ describe('resolveObjectValuesToArray', () => {
116116
);
117117
});
118118

119+
it('resolves Object.values when using methods', () => {
120+
const path = parse(
121+
['var foo = { boo: 1, foo: 2, bar(e) {} };', 'Object.values(foo);'].join(
122+
'\n',
123+
),
124+
);
125+
126+
expect(resolveObjectValuesToArray(path)).toEqualASTNode(
127+
builders.arrayExpression([builders.literal(1), builders.literal(2)]),
128+
);
129+
});
130+
119131
it('resolves Object.values but ignores duplicates', () => {
120132
const path = parse(
121133
[

src/utils/resolveObjectValuesToArray.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ export function resolveObjectToPropMap(
6767
if (error) return;
6868
const prop = propPath.value;
6969

70-
if (prop.kind === 'get' || prop.kind === 'set') return;
70+
if (prop.kind === 'get' || prop.kind === 'set' || prop.method === true) {
71+
return;
72+
}
7173

7274
if (
7375
t.Property.check(prop) ||

0 commit comments

Comments
 (0)