Skip to content

Allow decorators to be used with declare on class fields#19492

Merged
fisker merged 7 commits into
prettier:mainfrom
evoactivity:patch-1
Jun 29, 2026
Merged

Allow decorators to be used with declare on class fields#19492
fisker merged 7 commits into
prettier:mainfrom
evoactivity:patch-1

Conversation

@evoactivity

Copy link
Copy Markdown
Contributor

Description

Ember projects regularly use decorators on class fields with declare, this is a new addition to babel and the babel project makes this same change, as a patch, to test against prettier. The author of the change also suggested prettier should ignore DecoratorAbstractMethod errors.

Closes #19491

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.
  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

@evoactivity evoactivity changed the title Patch 1 Typecript/JavaScript - Allow decorators to be used with declare on class fields Jun 29, 2026
@evoactivity evoactivity changed the title Typecript/JavaScript - Allow decorators to be used with declare on class fields TS/JS - Allow decorators to be used with declare on class fields Jun 29, 2026
@fisker

fisker commented Jun 29, 2026

Copy link
Copy Markdown
Member

@evoactivity Please add removed tests from #19210 back, thank you!

git revert 5d7f64e should work

@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Deploy Preview for prettier ready!

Name Link
🔨 Latest commit 6cc672f
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/6a4253d3b2fd3300075e7ed6
😎 Deploy Preview https://deploy-preview-19492--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@evoactivity

Copy link
Copy Markdown
Contributor Author

@fisker tests have been added back 👍

@fisker

fisker commented Jun 29, 2026

Copy link
Copy Markdown
Member

Please add a changelog entry for this change. Instructions

@evoactivity

Copy link
Copy Markdown
Contributor Author

@fisker Changelog entry added. Let me know if there is anything else I missed.

@fisker fisker changed the base branch from main to v3.9.x June 29, 2026 11:07
@fisker fisker changed the title TS/JS - Allow decorators to be used with declare on class fields Allow decorators to be used with declare on class fields Jun 29, 2026
@fisker fisker changed the base branch from v3.9.x to main June 29, 2026 11:08
@pkg-pr-new

pkg-pr-new Bot commented Jun 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

yarn add https://pkg.pr.new/@prettier/plugin-hermes@19492.tgz
yarn add https://pkg.pr.new/@prettier/plugin-oxc@19492.tgz
yarn add https://pkg.pr.new/prettier@19492.tgz

commit: 6cc672f

@fisker fisker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Will release a patch version shortly.

@fisker fisker merged commit 330b83d into prettier:main Jun 29, 2026
36 checks passed
fisker added a commit that referenced this pull request Jun 29, 2026
Co-authored-by: fisker <lionkay@gmail.com>
sys-support pushed a commit to 3caravelle/renovate that referenced this pull request Jun 30, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [prettier](https://prettier.io) ([source](https://github.com/prettier/prettier)) | [`3.8.5` → `3.9.4`](https://renovatebot.com/diffs/npm/prettier/3.8.5/3.9.4) | ![age](https://developer.mend.io/api/mc/badges/age/npm/prettier/3.9.4?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/prettier/3.8.5/3.9.4?slim=true) |

---

### Release Notes

<details>
<summary>prettier/prettier (prettier)</summary>

### [`v3.9.4`](https://github.com/prettier/prettier/blob/HEAD/CHANGELOG.md#394)

[Compare Source](prettier/prettier@3.9.3...3.9.4)

[diff](prettier/prettier@3.9.3...3.9.4)

##### Angular: Format `@content(name)` -> `@content (name)` to align with other block syntax ([#&#8203;19499](prettier/prettier#19499) by [@&#8203;fisker](https://github.com/fisker))

<!-- prettier-ignore -->

```html
<!-- Input -->
<FancyButton [label]="title">
  @&#8203;content (icon) {
    <span>Icon!</span>
  }
  @&#8203;content (description) {
    <span>Description text</span>
  }
  <span>Other children</span>
</FancyButton>

<!-- Prettier 3.9.3 -->
<FancyButton [label]="title">
  @&#8203;content(icon) {
    <span>Icon!</span>
  }
  @&#8203;content(description) {
    <span>Description text</span>
  }
  <span>Other children</span>
</FancyButton>

<!-- Prettier 3.9.4 -->
<FancyButton [label]="title">
  @&#8203;content (icon) {
    <span>Icon!</span>
  }
  @&#8203;content (description) {
    <span>Description text</span>
  }
  <span>Other children</span>
</FancyButton>
```

### [`v3.9.3`](https://github.com/prettier/prettier/blob/HEAD/CHANGELOG.md#393)

[Compare Source](prettier/prettier@3.9.2...3.9.3)

[diff](prettier/prettier@3.9.1...3.9.3)

##### Markdown: Fix unexpected removal of characters in liquid syntax ([#&#8203;19489](prettier/prettier#19489) by [@&#8203;seiyab](https://github.com/seiyab))

<!-- prettier-ignore -->

```md
// Input
<!-- Input -->
{{ page.title
}} text

<!-- Prettier 3.9.1 -->
{{ page.title
 text

<!-- Prettier 3.9.3 -->
{{ page.title
}} text
```

##### TypeScript: Allow decorators to be used with declare on class fields ([#&#8203;19492](prettier/prettier#19492) by [@&#8203;evoactivity](https://github.com/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> {
  @&#8203;service declare server: ServerService;
}

// Prettier 3.9.1
// SyntaxError: Decorators can't be used with a declare field. (2:3)
//  1 | export default class ProjectStatusComponent extends Component<ProjectStatusSig> {
//> 2 |   @&#8203;service declare server: ServerService;
//    |   ^
//  3 | }

// Prettier 3.9.3
export default class ProjectStatusComponent extends Component<ProjectStatusSig> {
  @&#8203;service declare server: ServerService;
}
```

### [`v3.9.2`](prettier/prettier@3.9.1...3.9.2)

[Compare Source](prettier/prettier@3.9.1...3.9.2)

### [`v3.9.1`](https://github.com/prettier/prettier/blob/HEAD/CHANGELOG.md#391)

[Compare Source](prettier/prettier@3.9.0...3.9.1)

[diff](prettier/prettier@3.9.0...3.9.1)

##### CLI: Fix ignored file has been cached incorrectly ([#&#8203;19483](prettier/prettier#19483) by [@&#8203;kovsu](https://github.com/kovsu))

Bug details [#&#8203;18016](prettier/prettier#18016)

### [`v3.9.0`](https://github.com/prettier/prettier/blob/HEAD/CHANGELOG.md#390)

[Compare Source](prettier/prettier@3.8.5...3.9.0)

[diff](prettier/prettier@3.8.5...3.9.0)

🔗 [Release Notes](https://prettier.io/blog/2026/06/27/3.9.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi44MS4zIiwidXBkYXRlZEluVmVyIjoiNDIuODEuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Reviewed-on: https://git.3caravelle.net/3Caravelle/renovate/pulls/42
Co-authored-by: Renovate Bot <renovate-bot@3caravelle.com>
Co-committed-by: Renovate Bot <renovate-bot@3caravelle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[3.9.x] Babel's DecoratorAbstractMethod should be an ignored error code

2 participants