-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Open
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 pr-18186
Playground link
--parser typescriptInput:
type A = {
property: // Comment
B;
property2: /* Comment */
B
property3: /* Comment */
B
}
const A2 = {
property: // Comment
B,
property2: /* Comment */
B,
property3: /* Comment */ B
}
Output:
type A = {
property: B; // Comment
property2 /* Comment */: B;
property3 /* Comment */: B;
};
const A2 = {
// Comment
property: B,
/* Comment */ property2: B,
property3: /* Comment */ B,
};Expected output:
type A = {
property: // Comment
B;
property2 /* Comment */: B;
property3: /* Comment */ B;
};
const A2 = {
property: // Comment
B,
property2 /* Comment */: B,
property3: /* Comment */ B,
};
// or
type A = {
property: B; // Comment
property2 /* Comment */: B;
property3: /* Comment */ B;
};
const A2 = {
property: B, // Comment
property2 /* Comment */: B,
property3: /* Comment */ B,
};Why?
#18110 made some changes in the comments for PropertySignature, which caused property2: /* Comment */ B to be formatted as property2 /* Comment */ : B. I think the comment should keep its original place, that is said it should be formatted as `property2: /* Comment */ B
The expected output maintains consistency and keeps the comment position as similar as before.
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)