Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unnecessary parentheses for decorators (#11849)
* Remove unnecesary parans for typescript parser * Add tests * Update changelog
- Loading branch information
1 parent
c9b3518
commit 7acdac3
Showing
6 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
#### Fix formatting for tagged template decorators (#11717 by @sosukesuzuki) | ||
#### Remove unnecessary parentheses for decorators (#11717, #11849 by @sosukesuzuki) | ||
|
||
<!-- prettier-ignore --> | ||
```tsx | ||
// Input | ||
class Test { | ||
@foo`bar` | ||
test: string = "test" | ||
test1: string = "test" | ||
|
||
@test().x("global").y() | ||
test2: string = "test"; | ||
} | ||
|
||
// Prettier stable | ||
class Test { | ||
@(foo`bar`) | ||
test: string = "test" | ||
|
||
@(test().x("global").y()) | ||
test2: string = "test"; | ||
} | ||
|
||
// Prettier main | ||
class Test { | ||
@foo`bar` | ||
test: string = "test" | ||
|
||
@test().x("global").y() | ||
test2: string = "test"; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
tests/format/misc/typescript-babel-only/parenthesized-decorators-call-expression.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@(test().x("global").y()) | ||
class X {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
tests/format/misc/typescript-only/parenthesized-decorators-call-expression.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@(test().x("global").y()) | ||
class X {} |