Repository navigation
fat arrow Unexpected token in the Class #909
Description
Activity
This is because of class properties that are currently on stage 3 of ECMA proposal and does not support by acorn and escodegen
@iterion-mikehit you should use methods, like:
class Kruzya { // ... test() {console.log("test")} }
second way:
class Kruzya { constructor() { this.setScreen = () => {console.log("test")}; // typo but should work } }
Thank you I have a more complex JS code unfortunately rewrite it
Now this proposal in stage 4. Acorn just has added the support of this feature, but
estraverse/escodegenstill does not support it. I'll keep this issue open.I forked
estraversetoo, but as the first step we have to wait until these PRs will be merged:
eslint/js#486
eslint/eslint-scope#69After that, I'll try to implement this feature in my fork of
escodegenPR with the support of this feature in my fork of
escodegen
javascript-obfuscator/escodegen#3WIP PR to the obfuscator:
#916Still need to wait until
eslint/js#486
eslint/eslint-scope#69will be finished.
I'm having the same problem.
I'm trying to obfuscate several classes all of which have arrow function methods. In each file, the obfuscator reaches the first arrow function and throws this Error: ERROR at line 24: Unexpected token (24:18)
An example of the smallest class
import { xInit, yInit } from "../functions/displaySVG.js"; import { createSvgText} from "../functions/drawSVG.js"; import { currentUser } from "../script.js"; export default class Label { constructor(text, position) { this.text = text; this.coordinates = {x: xInit, y: yInit}; this.position = position; } drawLabel = () => { let matrixGroup = document.getElementById("matrixGroup"); let label = createSvgText( this.text, 13, "#333639", this.coordinates.x, this.coordinates.y, `mapLabel labl-${this.position} draggable` ); label.setAttribute("id", `labl-${this.position}`) label.setAttributeNS(null, "font-weight", "bold"); label.setAttributeNS(null, "text-decoration", "underline"); label.addEventListener("dblclick", currentUser.maps[0].deleteLabel); matrixGroup.appendChild(label); } setCoordinates = (x, y) => { this.coordinates.x = x; this.coordinates.y = y; } }Is the message here, we're waiting on...?
eslint/js#486
eslint/eslint-scope#69Sorry to hassle you
PR to the @types/estree
DefinitelyTyped/DefinitelyTyped#52832Any update on this?
I linked all related PR's. We have to wait until they all will be merged.
Could we please merge the PR: #916?
Thank you!
This PR cannot be merged right now. Wait until eslint/eslint-scope#71 will be merged
Reacted by regnaioReleased as
2.18.0
Hi, try this to obfuscatge with online obfuscator. Any idea why error is raising?
class alfaTest{
constructor() {
let test = {}
}
setScreen = () => {
console.log('test');
}
}
Raise an error
Error: ERROR at line 5: Unexpected token (5:14)