fix(typescript): inline method decorators should stay inlined (#5444)
parent
81a72cc2d6
commit
57b057cfa2
|
@ -102,7 +102,9 @@ function genericPrint(path, options, printPath, args) {
|
|||
node.type === "ClassMethod" ||
|
||||
node.type === "ClassProperty" ||
|
||||
node.type === "TSAbstractClassProperty" ||
|
||||
node.type === "ClassPrivateProperty"
|
||||
node.type === "ClassPrivateProperty" ||
|
||||
node.type === "MethodDefinition" ||
|
||||
node.type === "TSAbstractMethodDefinition"
|
||||
) {
|
||||
// their decorators are handled themselves
|
||||
} else if (
|
||||
|
@ -875,6 +877,9 @@ function printPathNoParens(path, options, print, args) {
|
|||
}
|
||||
case "MethodDefinition":
|
||||
case "TSAbstractMethodDefinition":
|
||||
if (n.decorators && n.decorators.length !== 0) {
|
||||
parts.push(printDecorators(path, options, print));
|
||||
}
|
||||
if (n.accessibility) {
|
||||
parts.push(n.accessibility + " ");
|
||||
}
|
||||
|
|
|
@ -116,6 +116,27 @@ class Greeter {
|
|||
|
||||
`;
|
||||
|
||||
exports[`mobx.ts - typescript-verify 1`] = `
|
||||
class X {
|
||||
@deco x() {
|
||||
return this.count * 2;
|
||||
}
|
||||
@deco get x() {
|
||||
return this.count * 2;
|
||||
}
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
class X {
|
||||
@deco x() {
|
||||
return this.count * 2;
|
||||
}
|
||||
@deco get x() {
|
||||
return this.count * 2;
|
||||
}
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
exports[`multiple.ts - typescript-verify 1`] = `
|
||||
class C {
|
||||
@f()
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
class X {
|
||||
@deco x() {
|
||||
return this.count * 2;
|
||||
}
|
||||
@deco get x() {
|
||||
return this.count * 2;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue