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

Comment in empty array type breaks code #13588

Closed
aczekajski opened this issue Oct 7, 2022 · 2 comments
Closed

Comment in empty array type breaks code #13588

aczekajski opened this issue Oct 7, 2022 · 2 comments
Labels
area:comments Issues with how Prettier prints comments lang:flow Issues affecting Flow-specific constructs (not general JS issues) lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) type:bug Issues identifying ugly output, or a defect in the program

Comments

@aczekajski
Copy link

aczekajski commented Oct 7, 2022

Prettier 2.7.1
Playground link

--parser typescript

Input:

interface X {
  x: [
    // x
  ];
}

Output:

interface X {
  x: [// x];
}

The code is broken and no longer parsable as correct typescript. This happens both with "typescript" and "babel-ts" parsers.

Expected behavior:
Output should stay the same as input.

This is similar to #9299 but there it breaks only if there's a colon before the comment but with typescript it breaks any empty array type.

@thorn0 thorn0 added type:bug Issues identifying ugly output, or a defect in the program area:comments Issues with how Prettier prints comments lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) lang:flow Issues affecting Flow-specific constructs (not general JS issues) labels Oct 7, 2022
@thorn0
Copy link
Member

thorn0 commented Oct 7, 2022

Related comment about refactoring of dangling comments: #13445 (comment)

@thorn0
Copy link
Member

thorn0 commented Oct 11, 2022

fixed by #13608

@thorn0 thorn0 closed this as completed Oct 11, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2023
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 lang:flow Issues affecting Flow-specific constructs (not general JS issues) lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

2 participants