Prettier 2.4.1
Playground link
Input:
@test().x('global').y()
class X {}
Output:
@(test().x("global").y())
class X {}
Expected behavior:
@test().x('global').y()
class X {}
In TypeScript, the two decorator usages (Input and Output above) are same. They will be compiled to JS like:
let X = class X {
};
X = __decorate([
// from the input
test().x('global').y()
// and from the output. they are same
(test().x('global').y())
], X);
But the Input's style (no parentheses) is easier to read and looks better. I found a related PR #5785 caused the issue.
Maybe Prettier should support parser based format behavior or parser based config? Only babel should add parentheses for decorators but typescript not.
Prettier 2.4.1
Playground link
Input:
Output:
Expected behavior:
In TypeScript, the two decorator usages (Input and Output above) are same. They will be compiled to JS like:
But the Input's style (no parentheses) is easier to read and looks better. I found a related PR #5785 caused the issue.
Maybe Prettier should support parser based format behavior or parser based config? Only
babelshould add parentheses for decorators buttypescriptnot.