don't output comma separator for decorator list and output Property decorators - fixes #1811

This commit is contained in:
Sebastian McKenzie 2015-06-25 12:23:45 +01:00
parent c8a5d7d970
commit 95d830fde0
5 changed files with 68 additions and 3 deletions

View File

@ -1,5 +1,5 @@
export function ClassDeclaration(node, print) {
print.list(node.decorators);
print.list(node.decorators, { separator: "" });
this.push("class");
if (node.id) {
@ -43,7 +43,7 @@ export function ClassBody(node, print) {
export function ClassProperty(node, print) {
print.list(node.decorators);
print.list(node.decorators, { separator: "" });
if (node.static) this.push("static ");
print.plain(node.key);
@ -58,7 +58,7 @@ export function ClassProperty(node, print) {
}
export function MethodDefinition(node, print) {
print.list(node.decorators);
print.list(node.decorators, { separator: "" });
if (node.static) {
this.push("static ");

View File

@ -33,6 +33,8 @@ export function ObjectExpression(node, print) {
export { ObjectExpression as ObjectPattern };
export function Property(node, print) {
print.list(node.decorators, { separator: "" });
if (node.method || node.kind === "get" || node.kind === "set") {
this._method(node, print);
} else {

View File

@ -0,0 +1,31 @@
var obj = {
@foo
@bar
foo: "bar",
@foo
@bar
foo() {},
@foo
get foo() {},
@bar
set bar(foo) {}
};
class Foo {
@foo
@bar
foo() {}
@foo
@bar
foo() {}
@foo
get foo() {}
@bar
set bar(foo) {}
}

View File

@ -0,0 +1,31 @@
var obj = {
@foo
@bar
foo: "bar",
@foo
@bar
foo() {},
@foo
get foo() {},
@bar
set bar(foo) {}
};
class Foo {
@foo
@bar
foo() {}
@foo
@bar
foo() {}
@foo
get foo() {}
@bar
set bar(foo) {}
}

View File

@ -32,6 +32,7 @@ _.each(helper.get("generation"), function (testSuite) {
strictMode: false,
sourceType: "module",
features: {
"es7.decorators": true,
"es7.comprehensions": true,
"es7.asyncFunctions": true,
"es7.exportExtensions": true,