diff --git a/src/fast-path.js b/src/fast-path.js index be5bc1ef48a3..7e346df66fc2 100644 --- a/src/fast-path.js +++ b/src/fast-path.js @@ -322,6 +322,12 @@ FastPath.prototype.needsParens = function(options) { (node.type === "TSTypeAssertionExpression" || node.type === "TSAsExpression") ); + case "Decorator": + return ( + parent.expression === node && + (node.type === "TSTypeAssertionExpression" || + node.type === "TSAsExpression") + ); case "BinaryExpression": case "LogicalExpression": { diff --git a/tests/typescript_decorators/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_decorators/__snapshots__/jsfmt.spec.js.snap index 226b949edec4..c715c5055a5c 100644 --- a/tests/typescript_decorators/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript_decorators/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,24 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`decorator-type-assertion.ts 1`] = ` +@(bind as ClassDecorator) +class Decorated { + +} + +@(bind) +class Decorated { + +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +@(bind as ClassDecorator) +class Decorated {} + +@(bind) +class Decorated {} + +`; + exports[`decorators.js 1`] = ` export class TestTextFileService { constructor( diff --git a/tests/typescript_decorators/decorator-type-assertion.ts b/tests/typescript_decorators/decorator-type-assertion.ts new file mode 100644 index 000000000000..8700b15929f5 --- /dev/null +++ b/tests/typescript_decorators/decorator-type-assertion.ts @@ -0,0 +1,9 @@ +@(bind as ClassDecorator) +class Decorated { + +} + +@(bind) +class Decorated { + +}