Allow decorators to be used with declare on class fields (#19492)
Co-authored-by: fisker <lionkay@gmail.com>
This commit is contained in:
1 parent
87acae6550
commit
330b83d7d5
7 files changed
+113
No files matched your search
@@ -0,0 +1,23 @@
|
||||
#### Allow decorators to be used with declare on class fields (#19492 by @evoactivity)
|
||||
|
||||
Extensively used within the Ember ecosystem, decorators with `declare` on class fields will ignore the babel parser error and allow Prettier to format the code without breaking it.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```ts
|
||||
// Input
|
||||
export default class ProjectStatusComponent extends Component<ProjectStatusSig> {
|
||||
@service declare server: ServerService;
|
||||
}
|
||||
|
||||
// Prettier stable
|
||||
// SyntaxError: Decorators can't be used with a declare field. (2:3)
|
||||
// 1 | export default class ProjectStatusComponent extends Component<ProjectStatusSig> {
|
||||
//> 2 | @service declare server: ServerService;
|
||||
// | ^
|
||||
// 3 | }
|
||||
|
||||
// Prettier main
|
||||
export default class ProjectStatusComponent extends Component<ProjectStatusSig> {
|
||||
@service declare server: ServerService;
|
||||
}
|
||||
```
|
||||
Reference in new issue
Block a user