Skip to content

Improve trailing comma comment handling#17782

Merged
JLHwung merged 6 commits intobabel:mainfrom
JLHwung:improve-trailing-comma-comment-handling
Mar 4, 2026
Merged

Improve trailing comma comment handling#17782
JLHwung merged 6 commits intobabel:mainfrom
JLHwung:improve-trailing-comma-comment-handling

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Feb 5, 2026

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

In this PR we apply trailing comma comment adjustment on more nodes.

@JLHwung JLHwung added pkg: parser PR: Polish (next major) 💅 A type of pull request used for our changelog categories for next major release labels Feb 5, 2026
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Feb 5, 2026

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61098

"type": "TSStringKeyword",
"start":19,"end":25,"loc":{"start":{"line":2,"column":5,"index":19},"end":{"line":2,"column":11,"index":25}}
},
"trailingComments": [
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trailing comment is not attached to the TSPropertySignature because the node ends at the trailing comma. This is a bit odd compared to other elements with trailing comma, probably because the property signature also supports ; as a separator.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 5, 2026

Open in StackBlitz

commit: 7b7bb98

@JLHwung JLHwung force-pushed the improve-trailing-comma-comment-handling branch from 21e4e69 to 7b7bb98 Compare March 4, 2026 16:22
case "ImportDeclaration":
adjustInnerComments(node, node.specifiers, commentWS);
break;
case "TSEnumDeclaration":
Copy link
Copy Markdown
Member

@liuxingbaoyu liuxingbaoyu Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was TSEnumDeclaration removed?

I understand, the default branches are the same.

@JLHwung JLHwung merged commit 2ed42c4 into babel:main Mar 4, 2026
55 checks passed
@JLHwung JLHwung deleted the improve-trailing-comma-comment-handling branch March 4, 2026 19:07
@nicolo-ribaudo nicolo-ribaudo added the PR: Polish 💅 A type of pull request used for our changelog categories label Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: parser PR: Polish 💅 A type of pull request used for our changelog categories PR: Polish (next major) 💅 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants