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

Comments in typescript type unions move to incorrect place #10344

Closed
Naddiseo opened this issue Feb 18, 2021 · 3 comments · Fixed by #10457
Closed

Comments in typescript type unions move to incorrect place #10344

Naddiseo opened this issue Feb 18, 2021 · 3 comments · Fixed by #10457
Labels
area:comments Issues with how Prettier prints comments area:union types lang:flow Issues affecting Flow-specific constructs (not general JS issues) 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

@Naddiseo
Copy link
Contributor

Prettier 2.2.1
Playground link

--parser typescript
--trailing-comma all

Input:

type Foo = "1" | "2" /* two */ | "3";

const Foo = "1" | "2" /*two*/ | "3";

Output:

type Foo = "1" | "2" | /* two */ "3";

const Foo = "1" | "2" /*two*/ | "3";

Expected behavior:
The comment should stay on the correct side of the | (like it does with const):

type Foo = "1" | "2" /* two */ | "3";

const Foo = "1" | "2" /*two*/ | "3";
@thorn0 thorn0 added area:comments Issues with how Prettier prints comments lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) type:bug Issues identifying ugly output, or a defect in the program lang:flow Issues affecting Flow-specific constructs (not general JS issues) area:union types labels Feb 18, 2021
@prabhuHalodoc
Copy link

@thorn0 I am working on this issue.

@thorn0 thorn0 linked a pull request Mar 2, 2021 that will close this issue
3 tasks
@thorn0
Copy link
Member

thorn0 commented Mar 2, 2021

@prabhuHalodoc Sorry, this has been fixed by the Babel team. Now that we updated the Babel parser, we can remove workarounds that caused this bug. See #10457 for more details.

@prabhuHalodoc
Copy link

Thank you @thorn0 for the update.

@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 Jun 2, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:comments Issues with how Prettier prints comments area:union types lang:flow Issues affecting Flow-specific constructs (not general JS issues) 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.

3 participants