diff --git a/src/proxy/object.ts b/src/proxy/object.ts index 8ce97ec..cfe911b 100644 --- a/src/proxy/object.ts +++ b/src/proxy/object.ts @@ -28,7 +28,7 @@ export function proxifyObject( prop.key.type === "BooleanLiteral") && prop.key.value.toString() === key ) { - return (prop.value as any).value; + return (prop.value as any).value ?? prop.value; } } }; diff --git a/test/object.test.ts b/test/object.test.ts index 677598a..eb6514d 100644 --- a/test/object.test.ts +++ b/test/object.test.ts @@ -14,6 +14,8 @@ export default { foo() {}, 1: 3, [true]: 4, + "c": { key: 5 }, + 'd': { key: 6 }, } } `.trim(), @@ -23,6 +25,8 @@ 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", @@ -30,6 +34,8 @@ export default { "foo", "1", "true", + "c", + "d", ] `); @@ -42,6 +48,8 @@ export default { "foo", "1", "true", + "c", + "d", "a-b-c", ] `); @@ -56,6 +64,8 @@ export default { foo() {}, 1: 3, [true]: 4, + c: { key: 5 }, + d: { key: 6 }, \\"a-b-c\\": 3, }, };"