Skip to content

Commit

Permalink
Fix treatment of Identifier nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Nov 15, 2023
1 parent 8d8291f commit 6f5400f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions development/parse-extension-translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ const evaluateAST = (node) => {
if (node.type === "ObjectExpression") {
const object = {};
for (const { key, value } of node.properties) {
object[evaluateAST(key)] = evaluateAST(value);
// Normally Identifier refers to a variable, but inside of key we treat it as a string.
let evaluatedKey;
if (key.type === "Identifier") {
evaluatedKey = key.name;
} else {
evaluatedKey = evaluateAST(key);
}

object[evaluatedKey] = evaluateAST(value);
}
return object;
}

if (node.type === "Identifier") {
return node.name;
}

console.error(`Can't evaluate node:`, node);
throw new Error(`Can't evaluate ${node.type} node at build-time`);
};
Expand Down

0 comments on commit 6f5400f

Please sign in to comment.