Skip to content

Support static class fields #443

Description

@pYr0x

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;
        },

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions