parent
e16478ef80
commit
ccda4c7115
|
@ -74,7 +74,6 @@ function genericPrint(path, options, printPath, args) {
|
||||||
return options.originalText.slice(util.locStart(node), util.locEnd(node));
|
return options.originalText.slice(util.locStart(node), util.locEnd(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
const parts = [];
|
|
||||||
let needsParens = false;
|
let needsParens = false;
|
||||||
const linesWithoutParens = getPrintFunction(options)(
|
const linesWithoutParens = getPrintFunction(options)(
|
||||||
path,
|
path,
|
||||||
|
@ -87,6 +86,7 @@ function genericPrint(path, options, printPath, args) {
|
||||||
return linesWithoutParens;
|
return linesWithoutParens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const decorators = [];
|
||||||
if (
|
if (
|
||||||
node.decorators &&
|
node.decorators &&
|
||||||
node.decorators.length > 0 &&
|
node.decorators.length > 0 &&
|
||||||
|
@ -103,7 +103,6 @@ function genericPrint(path, options, printPath, args) {
|
||||||
prefix = "";
|
prefix = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// #1817
|
|
||||||
if (
|
if (
|
||||||
node.decorators.length === 1 &&
|
node.decorators.length === 1 &&
|
||||||
node.type !== "ClassDeclaration" &&
|
node.type !== "ClassDeclaration" &&
|
||||||
|
@ -118,10 +117,10 @@ function genericPrint(path, options, printPath, args) {
|
||||||
decorator.arguments[0].type === "Identifier" ||
|
decorator.arguments[0].type === "Identifier" ||
|
||||||
decorator.arguments[0].type === "MemberExpression")))))
|
decorator.arguments[0].type === "MemberExpression")))))
|
||||||
) {
|
) {
|
||||||
separator = " ";
|
separator = line;
|
||||||
}
|
}
|
||||||
|
|
||||||
parts.push(prefix, printPath(decoratorPath), separator);
|
decorators.push(prefix, printPath(decoratorPath), separator);
|
||||||
}, "decorators");
|
}, "decorators");
|
||||||
} else if (
|
} else if (
|
||||||
util.isExportDeclaration(node) &&
|
util.isExportDeclaration(node) &&
|
||||||
|
@ -137,7 +136,7 @@ function genericPrint(path, options, printPath, args) {
|
||||||
decorator.type === "TSDecorator"
|
decorator.type === "TSDecorator"
|
||||||
? ""
|
? ""
|
||||||
: "@";
|
: "@";
|
||||||
parts.push(prefix, printPath(decoratorPath), line);
|
decorators.push(prefix, printPath(decoratorPath), hardline);
|
||||||
},
|
},
|
||||||
"declaration",
|
"declaration",
|
||||||
"decorators"
|
"decorators"
|
||||||
|
@ -156,6 +155,7 @@ function genericPrint(path, options, printPath, args) {
|
||||||
node.needsParens = needsParens;
|
node.needsParens = needsParens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const parts = [];
|
||||||
if (needsParens) {
|
if (needsParens) {
|
||||||
parts.unshift("(");
|
parts.unshift("(");
|
||||||
}
|
}
|
||||||
|
@ -166,6 +166,9 @@ function genericPrint(path, options, printPath, args) {
|
||||||
parts.push(")");
|
parts.push(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (decorators.length > 0) {
|
||||||
|
return group(concat(decorators.concat(parts)));
|
||||||
|
}
|
||||||
return concat(parts);
|
return concat(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,10 @@ class Class3 {
|
||||||
class Bar {
|
class Bar {
|
||||||
@decorated method() {}
|
@decorated method() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MyContainerComponent {
|
||||||
|
@ContentChildren(MyComponent) components: QueryListSomeBigName<MyComponentThat>;
|
||||||
|
}
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@d1
|
@d1
|
||||||
@d2(foo)
|
@d2(foo)
|
||||||
|
@ -130,4 +134,9 @@ class Bar {
|
||||||
method() {}
|
method() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MyContainerComponent {
|
||||||
|
@ContentChildren(MyComponent)
|
||||||
|
components: QueryListSomeBigName<MyComponentThat>;
|
||||||
|
}
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -43,3 +43,7 @@ class Class3 {
|
||||||
class Bar {
|
class Bar {
|
||||||
@decorated method() {}
|
@decorated method() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MyContainerComponent {
|
||||||
|
@ContentChildren(MyComponent) components: QueryListSomeBigName<MyComponentThat>;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue