fix(formatter): handle same-line comment after pipe in single-member union types#21824
fix(formatter): handle same-line comment after pipe in single-member union types#21824babu-ch wants to merge 2 commits into
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
e795087 to
89f750e
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
That is a suspicious issue that may be a bug in Prettier rather than in us, even though the output matched Prettier. Need to double-check in #18717 |
|
@Dunqing |
Can you try to double-check first? I forgot half the issues I listed in that and just remembered that the union with comments case in Prettier is very buggy. 😅 |
|
Double-checked the union-related issues in #18717. This case doesn't appear to match any of them. |
…ment-after-pipe-same-line
…rmatting (#21915) Fixes #21914, Fixes #21792, Supersedes #21824. Tests for union type are taken from #21824. ### Comment printing Changes to comment printing for single member union/intersection types try to mimic: https://github.com/prettier/prettier/blob/f5e3980c3085f6fb2b166c8e3f91e8db317d6eb2/src/main/comments/attach.js#L183-L190 Where own-line comments are leading, and: https://github.com/prettier/prettier/blob/f5e3980c3085f6fb2b166c8e3f91e8db317d6eb2/src/main/comments/attach.js#L200-L206 Where end-of-line comments are trailing (note that this doesn't apply to block comments, see https://github.com/prettier/prettier/blob/870b6df76058cc6c1c23418524d0272141c50677/src/language-js/comments/handle-comments.js#L764), and: https://github.com/prettier/prettier/blob/f5e3980c3085f6fb2b166c8e3f91e8db317d6eb2/src/main/comments/attach.js#L324-L328 Where inline comments are leading if they're separated only by whitespace, open parentheses or other comments from the node after them. Because of that, current behavior is to consider inline comments trailing if they're before the `&` or `|` symbol (as they can't be leading, because `&` and `|` aren't whitespace). --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Yuji Sugiura <6259812+leaysgur@users.noreply.github.com>
|
Fixed by #21915 (Anyway, thank you for your assistance~!) |
…rmatting (#21915) Fixes #21914, Fixes #21792, Supersedes #21824. Tests for union type are taken from #21824. ### Comment printing Changes to comment printing for single member union/intersection types try to mimic: https://github.com/prettier/prettier/blob/f5e3980c3085f6fb2b166c8e3f91e8db317d6eb2/src/main/comments/attach.js#L183-L190 Where own-line comments are leading, and: https://github.com/prettier/prettier/blob/f5e3980c3085f6fb2b166c8e3f91e8db317d6eb2/src/main/comments/attach.js#L200-L206 Where end-of-line comments are trailing (note that this doesn't apply to block comments, see https://github.com/prettier/prettier/blob/870b6df76058cc6c1c23418524d0272141c50677/src/language-js/comments/handle-comments.js#L764), and: https://github.com/prettier/prettier/blob/f5e3980c3085f6fb2b166c8e3f91e8db317d6eb2/src/main/comments/attach.js#L324-L328 Where inline comments are leading if they're separated only by whitespace, open parentheses or other comments from the node after them. Because of that, current behavior is to consider inline comments trailing if they're before the `&` or `|` symbol (as they can't be leading, because `&` and `|` aren't whitespace). --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Yuji Sugiura <6259812+leaysgur@users.noreply.github.com>
Closes #21792