Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow decorator on private members and class expressions (#14548)
- Loading branch information
Showing
8 changed files
with
97 additions
and
91 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#### Allow decorators on private members and class expressions (#14548 by @fisker) | ||
|
||
<!-- prettier-ignore --> | ||
```ts | ||
// Input | ||
class A { | ||
@decorator() | ||
#privateMethod () {} | ||
} | ||
|
||
// Prettier stable | ||
SyntaxError: Decorators are not valid here. (2:3) | ||
1 | class A { | ||
> 2 | @decorator() | ||
| ^^^^^^^^^^^^ | ||
3 | #privateMethod () {} | ||
4 | } | ||
|
||
// Prettier main | ||
class A { | ||
@decorator() | ||
#privateMethod() {} | ||
} | ||
``` |
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
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,6 +1,5 @@ | ||
const errors = { | ||
flow: true, | ||
typescript: true, | ||
acorn: true, | ||
espree: true, | ||
}; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[ | ||
@decorator() class {}, | ||
@decorator() class A {}, | ||
]; | ||
|
||
class A { | ||
@decorator() accessor #field; | ||
} | ||
|
||
class B { | ||
@decorator() #field () {} | ||
} |
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: 1 addition & 1 deletion
2
tests/format/typescript/type-arguments-bit-shift-left-like/jsfmt.spec.js
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,3 +1,3 @@ | ||
run_spec(__dirname, ["typescript"], { | ||
errors: { typescript: ["3.ts", "4.ts", "5.tsx"] }, | ||
errors: { typescript: ["3.ts", "5.tsx"] }, | ||
}); |