Closed
Description
Describe the bug:
When the code to confuse contains a class with a static field, an error is thrown and code generation does not complete.
Config and Small code sample
Repro:
require("js-confuser").obfuscate(`
class C {
static v = 42;
}
`, {
target: "node",
preset: "low",
}).then(obfuscated => {
console.log(obfuscated)
})
Expected behavior
This example should pass and generate the corresponding, confused code.
Actual behavior
It throws an error:
xxx/node_modules/escodegen/escodegen.js:2525
result = this[type](expr, precedence, flags);
^
TypeError: this[type] is not a function
at CodeGenerator.generateExpression (xxx/node_modules/escodegen/escodegen.js:2525:28)
at xxx/node_modules/escodegen/escodegen.js:1133:38
at withIndent (xxx/node_modules/escodegen/escodegen.js:581:9)
at CodeGenerator.ClassBody (xxx/node_modules/escodegen/escodegen.js:1128:13)
at CodeGenerator.generateStatement (xxx/node_modules/escodegen/escodegen.js:2538:33)
at CodeGenerator.ClassDeclaration (xxx/node_modules/escodegen/escodegen.js:1159:30)
at CodeGenerator.generateStatement xxx/node_modules/escodegen/escodegen.js:2538:33)
at CodeGenerator.Program (xxx/node_modules/escodegen/escodegen.js:1718:43)
at CodeGenerator.generateStatement (xxx/node_modules/escodegen/escodegen.js:2538:33)
at generateInternal (xxx/node_modules/escodegen/escodegen.js:2559:28)
Additional context
It seems that in CodeGenerator.prototype.generateExpression()
, the expression this[type]
is undefined when type
is PropertyDefinition
.