Print parens around type assertions for decorators (#3329)
parent
9b4ecec183
commit
2dd76c6a95
|
@ -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": {
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`decorator-type-assertion.ts 1`] = `
|
||||
@(bind as ClassDecorator)
|
||||
class Decorated {
|
||||
|
||||
}
|
||||
|
||||
@(<ClassDecorator>bind)
|
||||
class Decorated {
|
||||
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@(bind as ClassDecorator)
|
||||
class Decorated {}
|
||||
|
||||
@(<ClassDecorator>bind)
|
||||
class Decorated {}
|
||||
|
||||
`;
|
||||
|
||||
exports[`decorators.js 1`] = `
|
||||
export class TestTextFileService {
|
||||
constructor(
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
@(bind as ClassDecorator)
|
||||
class Decorated {
|
||||
|
||||
}
|
||||
|
||||
@(<ClassDecorator>bind)
|
||||
class Decorated {
|
||||
|
||||
}
|
Loading…
Reference in New Issue