don't output comma separator for decorator list and output Property decorators - fixes #1811
This commit is contained in:
parent
c8a5d7d970
commit
95d830fde0
@ -1,5 +1,5 @@
|
|||||||
export function ClassDeclaration(node, print) {
|
export function ClassDeclaration(node, print) {
|
||||||
print.list(node.decorators);
|
print.list(node.decorators, { separator: "" });
|
||||||
this.push("class");
|
this.push("class");
|
||||||
|
|
||||||
if (node.id) {
|
if (node.id) {
|
||||||
@ -43,7 +43,7 @@ export function ClassBody(node, print) {
|
|||||||
|
|
||||||
|
|
||||||
export function ClassProperty(node, print) {
|
export function ClassProperty(node, print) {
|
||||||
print.list(node.decorators);
|
print.list(node.decorators, { separator: "" });
|
||||||
|
|
||||||
if (node.static) this.push("static ");
|
if (node.static) this.push("static ");
|
||||||
print.plain(node.key);
|
print.plain(node.key);
|
||||||
@ -58,7 +58,7 @@ export function ClassProperty(node, print) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function MethodDefinition(node, print) {
|
export function MethodDefinition(node, print) {
|
||||||
print.list(node.decorators);
|
print.list(node.decorators, { separator: "" });
|
||||||
|
|
||||||
if (node.static) {
|
if (node.static) {
|
||||||
this.push("static ");
|
this.push("static ");
|
||||||
|
|||||||
@ -33,6 +33,8 @@ export function ObjectExpression(node, print) {
|
|||||||
export { ObjectExpression as ObjectPattern };
|
export { ObjectExpression as ObjectPattern };
|
||||||
|
|
||||||
export function Property(node, print) {
|
export function Property(node, print) {
|
||||||
|
print.list(node.decorators, { separator: "" });
|
||||||
|
|
||||||
if (node.method || node.kind === "get" || node.kind === "set") {
|
if (node.method || node.kind === "get" || node.kind === "set") {
|
||||||
this._method(node, print);
|
this._method(node, print);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
31
test/core/fixtures/generation/types/Decorator/actual.js
Normal file
31
test/core/fixtures/generation/types/Decorator/actual.js
Normal 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) {}
|
||||||
|
}
|
||||||
31
test/core/fixtures/generation/types/Decorator/expected.js
Normal file
31
test/core/fixtures/generation/types/Decorator/expected.js
Normal 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) {}
|
||||||
|
}
|
||||||
@ -32,6 +32,7 @@ _.each(helper.get("generation"), function (testSuite) {
|
|||||||
strictMode: false,
|
strictMode: false,
|
||||||
sourceType: "module",
|
sourceType: "module",
|
||||||
features: {
|
features: {
|
||||||
|
"es7.decorators": true,
|
||||||
"es7.comprehensions": true,
|
"es7.comprehensions": true,
|
||||||
"es7.asyncFunctions": true,
|
"es7.asyncFunctions": true,
|
||||||
"es7.exportExtensions": true,
|
"es7.exportExtensions": true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user