Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support static class fields #443

Open
pYr0x opened this issue Mar 27, 2021 · 5 comments · May be fixed by #465
Open

Support static class fields #443

pYr0x opened this issue Mar 27, 2021 · 5 comments · May be fixed by #465

Comments

@pYr0x
Copy link

pYr0x commented Mar 27, 2021

i was playing around with AST by using acorn.
Acorn has a plugin to parse code with static class fields. https://github.com/acornjs/acorn-static-class-features
Unfortuallity escodegen can't handle this feature. So i wrote a function that generates a static assignment from the AST provided by acorn.
if you want this snippet inside your codebase i can contribute and create a PR.

PropertyDefinition: function (expr, precedence, flags) {
          var result;
          if (expr['static']) {
            result = ['static' + space];
          } else {
            result = [];
          }
          result.push(this.generateAssignment(expr.key, expr.value, '=', precedence, flags));
          result.push(this.semicolon(flags));
          return result;
        },
@ajvincent
Copy link

Peanut gallery observation: I'm guessing this won't work until at least #438 lands, and that one I just noticed can't work with the Node versions this project tests for. I'm pretty sure based on Mozilla's documentation this won't work until Node 12+ is the minimum version escodegen supports...

Which is really unfortunate.

@sanex3339
Copy link
Contributor

This feature just has been implemented in my fork:
https://www.npmjs.com/package/@javascript-obfuscator/escodegen

PR:
javascript-obfuscator#3

@imtaotao
Copy link

imtaotao commented Jan 7, 2022

I have the same problem, but the problem seems to still exist.

@stepankuzmin
Copy link

Same problem here, PropertyDefinition is missing.

kevincox added a commit to kevincox/escodegen that referenced this issue Apr 7, 2024
@kevincox kevincox linked a pull request Apr 7, 2024 that will close this issue
kevincox added a commit to kevincox/escodegen that referenced this issue Apr 7, 2024
kevincox added a commit to kevincox/escodegen that referenced this issue Apr 7, 2024
kevincox added a commit to kevincox/escodegen that referenced this issue Apr 7, 2024
@kevincox
Copy link

kevincox commented Apr 7, 2024

I implemented this: #465

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants