Skip to content

Commit

Permalink
fix: quoted properties of ObjectExpression not in exports proxy (#94)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Lichter <[email protected]>
Co-authored-by: Anthony Fu <[email protected]>
  • Loading branch information
3 people committed Nov 11, 2023
1 parent 32be90e commit 46c950d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/proxy/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function proxifyObject<T extends object>(
prop.key.type === "BooleanLiteral") &&
prop.key.value.toString() === key
) {
return (prop.value as any).value;
return (prop.value as any).value ?? prop.value;
}
}
};
Expand Down
10 changes: 10 additions & 0 deletions test/object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default {
foo() {},
1: 3,
[true]: 4,
"c": { key: 5 },
'd': { key: 6 },
}
}
`.trim(),
Expand All @@ -23,13 +25,17 @@ export default {
expect(mod.exports.default.foo["a-b"]).toBe(2);
expect(mod.exports.default.foo[1]).toBe(3);
expect(mod.exports.default.foo.true).toBe(4);
expect(mod.exports.default.foo.c?.key).toBe(5);
expect(mod.exports.default.foo.d?.key).toBe(6);
expect(Object.keys(mod.exports.default.foo)).toMatchInlineSnapshot(`
[
"a",
"a-b",
"foo",
"1",
"true",
"c",
"d",
]
`);

Expand All @@ -42,6 +48,8 @@ export default {
"foo",
"1",
"true",
"c",
"d",
"a-b-c",
]
`);
Expand All @@ -56,6 +64,8 @@ export default {
foo() {},
1: 3,
[true]: 4,
c: { key: 5 },
d: { key: 6 },
\\"a-b-c\\": 3,
},
};"
Expand Down

0 comments on commit 46c950d

Please sign in to comment.