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 6cb8df3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 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,21 @@
];
},

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

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

Expand Down Expand Up @@ -2513,6 +2532,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 6cb8df3

Please sign in to comment.