diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 0018d2de4..6c4225ffd 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -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 + " "); } diff --git a/tests/decorators-ts/__snapshots__/jsfmt.spec.js.snap b/tests/decorators-ts/__snapshots__/jsfmt.spec.js.snap index c57fd208a..7725db439 100644 --- a/tests/decorators-ts/__snapshots__/jsfmt.spec.js.snap +++ b/tests/decorators-ts/__snapshots__/jsfmt.spec.js.snap @@ -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() diff --git a/tests/decorators-ts/mobx.ts b/tests/decorators-ts/mobx.ts new file mode 100644 index 000000000..a453cb153 --- /dev/null +++ b/tests/decorators-ts/mobx.ts @@ -0,0 +1,8 @@ +class X { + @deco x() { + return this.count * 2; + } + @deco get x() { + return this.count * 2; + } +}