Skip to content

Commit

Permalink
Support class field declarations.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincox committed Apr 7, 2024
1 parent 899cfdf commit 9fff6ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions escodegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2161,6 +2161,10 @@
return join(result, fragment);
},

PrivateIdentifier: function(expr, precedence, flags) {
return toSourceNodeWhenNeeded('#' + expr.name, expr);
},

Property: function (expr, precedence, flags) {
if (expr.kind === 'get' || expr.kind === 'set') {
return [
Expand Down Expand Up @@ -2192,6 +2196,22 @@
];
},

PropertyDefinition: function(expr, precedence, flags) {
var keywords = [];
if (expr.static) {
keywords.push('static');
}

return join(keywords, [
this.generatePropertyKey(expr.key, expr.computed),
space,
'=',
space,
this.generateExpression(expr.value, Precedence.Assignment, E_TTT),
this.semicolon(flags),
]);
},

ObjectExpression: function (expr, precedence, flags) {
var multiline, result, fragment, that = this;

Expand Down Expand Up @@ -2513,6 +2533,9 @@
return generateVerbatim(expr, precedence);
}

if (!(type in this)) {
throw new Error('Unknown node type: ' + type);
}
result = this[type](expr, precedence, flags);


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"source-map": "~0.6.1"
},
"devDependencies": {
"acorn": "^8.0.4",
"acorn": "^8.2.0",
"bluebird": "^3.4.7",
"bower-registry-client": "^1.0.0",
"chai": "^4.2.0",
Expand Down

0 comments on commit 9fff6ed

Please sign in to comment.