You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Object keys written through the proxy cannot be read back when they are not identifiers #187
import{parseModule,generateCode}from"magicast";import{deepMergeObject}from"magicast/helpers";constmod=parseModule("export default {}");mod.exports.default.alias={"@": "./src"};constalias=mod.exports.default.alias;alias["@"];// undefinedObject.keys(alias);// []"@"inalias;// falsealias["@"]="./app";generateCode(mod).code;// export default { alias: { "@": "./src", "@": "./app" }};constmod2=parseModule("export default {}");deepMergeObject(mod2.exports.default,{server: {proxy: {"/api": {target: "http://localhost:3000"}}}});deepMergeObject(mod2.exports.default,{server: {proxy: {"/api": {changeOrigin: true}}}});// server.proxy now has two "/api" entries instead of one merged entry
Describe the bug
literalToAst builds object keys that are not valid identifiers with b.literal(key), which gives a Literal key node. getPropName in src/proxy/object.ts only handles Identifier, StringLiteral, NumericLiteral and BooleanLiteral, so get, set, delete, Object.keys and in cannot find those keys. A later write appends a duplicate property.
Expected: alias["@"] is "./src", and assigning it again replaces the value. Actual: undefined, and the generated code has duplicate keys.
Activity