Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decorators on accessor private fields report SyntaxError #14547

Closed
weareoutman opened this issue Mar 21, 2023 · 5 comments · Fixed by #14548
Closed

Decorators on accessor private fields report SyntaxError #14547

weareoutman opened this issue Mar 21, 2023 · 5 comments · Fixed by #14548
Assignees
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@weareoutman
Copy link

Prettier 2.8.5
Playground link

--parser typescript

Input:

class A {
  @dec() accessor #field;
}

Output:

SyntaxError: Decorators are not valid here. (2:3)
  1 | class A {
> 2 |   @dec() accessor #field;
    |   ^^^^^^
  3 | }

Expected behavior:

No SyntaxError. Change the parser from "typescript" to "babel-ts" will make it work.

Prettier 2.8.4 works fine, seems 2.8.5 introduced this.

@weareoutman weareoutman changed the title Decorator on an accessor private fields report SyntaxError Decorators on accessor private fields report SyntaxError Mar 21, 2023
@fisker
Copy link
Sponsor Member

fisker commented Mar 21, 2023

TypeScript seems don't allow it playground

@weareoutman
Copy link
Author

weareoutman commented Mar 21, 2023

You should unset the experimentalDecorators option. While it's enabled, it uses stage 2 decorator proposal, not the latest stage 3 proposal

weareoutman added a commit to easyops-cn/next-core that referenced this issue Mar 21, 2023
@fisker fisker added type:bug Issues identifying ugly output, or a defect in the program lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) labels Mar 21, 2023
@fisker fisker self-assigned this Mar 21, 2023
@fisker
Copy link
Sponsor Member

fisker commented Mar 21, 2023

Thanks for reporting this issue, I'll release a fix once #14548 passes tests.

@weareoutman
Copy link
Author

👍 That's quick! thanks

@fisker
Copy link
Sponsor Member

fisker commented Mar 21, 2023

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Nov 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants