generator: add support for method properties and computed keys and shorthand
This commit is contained in:
parent
0def62b918
commit
5c5348537d
@ -22,7 +22,7 @@ exports.ObjectPattern = function (node, print) {
|
|||||||
this.push(" ");
|
this.push(" ");
|
||||||
} else {
|
} else {
|
||||||
this.newline();
|
this.newline();
|
||||||
this.printJoin(print, props, ",\n", true);
|
this.printJoin(print, props, ",\n", { indent: true });
|
||||||
this.newline();
|
this.newline();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,9 +34,17 @@ exports.ObjectPattern = function (node, print) {
|
|||||||
|
|
||||||
exports.Property = function (node, print) {
|
exports.Property = function (node, print) {
|
||||||
if (node.method || node.kind === "get" || node.kind === "set") {
|
if (node.method || node.kind === "get" || node.kind === "set") {
|
||||||
throw new Error("Property");
|
this._method(node, print);
|
||||||
|
} else {
|
||||||
|
if (node.computed) {
|
||||||
|
this.push("[");
|
||||||
|
print(node.key);
|
||||||
|
this.push("]");
|
||||||
} else {
|
} else {
|
||||||
print(node.key);
|
print(node.key);
|
||||||
|
if (node.shorthand) return;
|
||||||
|
}
|
||||||
|
|
||||||
this.push(": ");
|
this.push(": ");
|
||||||
print(node.value);
|
print(node.value);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user