-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Trailing comment after empty method signature moves before parentheses #18835
Copy link
Copy link
Closed
Copy link
Labels
area:commentsIssues with how Prettier prints commentsIssues with how Prettier prints commentslang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)Issues affecting TypeScript-specific constructs (not general JS issues)
Description
Prettier 3.8.1
Playground link
--parser babel-tsInput:
prettier/tests/format/typescript/comments/method_types.ts
Lines 1 to 10 in 812a4d0
| interface foo1 { | |
| bar3/* foo */ (/* baz */) // bat | |
| bar/* foo */ ? /* bar */ (/* baz */) /* bat */; | |
| bar2/* foo */ (/* baz */) /* bat */ | |
| } | |
| interface foo2 { | |
| bar/* foo */ ? /* bar */ (bar: /* baz */ string): /* bat */ string; | |
| } | |
class foo1 {
bar() /* bat */;
}
class Test {
foo (/* 2 */) /* 3 */;
}Output:
class foo1 {
bar /* bat */();
}
class Test {
foo /* 3 */(/* 2 */);
}Expected output:
Same as input
class foo1 {
bar() /* bat */;
}
class Test {
foo(/* 2 */) /* 3 */;
}Why?
Should keep the comments in their original place rather than break the order and move them to an incorrect place.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:commentsIssues with how Prettier prints commentsIssues with how Prettier prints commentslang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)Issues affecting TypeScript-specific constructs (not general JS issues)