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

Incorrect formatting for auto-accessors with comments #14036

Closed
weareoutman opened this issue Dec 19, 2022 · 2 comments · Fixed by #14038
Closed

Incorrect formatting for auto-accessors with comments #14036

weareoutman opened this issue Dec 19, 2022 · 2 comments · Fixed by #14038
Assignees
Labels
lang:javascript Issues affecting JS 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.1
Playground link

# Options (if any):

Input:

class A {
  @dec()
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  // @ts-ignore
  accessor b;
}

Output:

class A {
  @dec()
  accessor // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  // @ts-ignore
  b;
}

Expected behavior:
The comments should not be placed between the keyword accessor and the identifier b, which causes the accessor to be treated as a class field instead of a keyword. Expected:

class A {
  @dec()
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  // @ts-ignore
  accessor b;
}
@fisker fisker added type:bug Issues identifying ugly output, or a defect in the program lang:javascript Issues affecting JS labels Dec 19, 2022
@fisker
Copy link
Sponsor Member

fisker commented Dec 19, 2022

This is actually bug in TypeScript microsoft/TypeScript#51707

@weareoutman
Copy link
Author

But I think here the issue has nothing todo with that bug in TypeScript.

My input is accessor b with no line terminators. The prettier formatted that into separated lines, which according to the spec draft, is not matching with accessor syntax, but two separated field properties.

@fisker fisker self-assigned this Dec 19, 2022
@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 28, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 28, 2023
medikoo pushed a commit to medikoo/prettier-elastic that referenced this issue Jan 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:javascript Issues affecting JS 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