Skip to content

fix: preserve trailing comma in optional call args#17781

Merged
nicolo-ribaudo merged 2 commits intobabel:mainfrom
JLHwung:unify-expression-argument-print
Feb 13, 2026
Merged

fix: preserve trailing comma in optional call args#17781
nicolo-ribaudo merged 2 commits intobabel:mainfrom
JLHwung:unify-expression-argument-print

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Feb 5, 2026

Q                       A
Fixed Issues? Babel does not preserve the trailing comma in the last argument of an optional call expression when experimental_preserveFormat: true
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This PR extracts the arguments printing logic shared among NewExpression, CallExpression and OptionalCallExpression. As a result, it also fixes the issue mentioned above as previously the second argument printTrailingSeparator of the printList method was always false in the OptionalCallExpression generator.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: generator 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/60869

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 5, 2026

Open in StackBlitz

commit: c7d05f4

@JLHwung JLHwung added PR: Bug Fix (next major) 🐛 A type of pull request used for our changelog categories for next major release and removed PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels Feb 5, 2026
@nicolo-ribaudo nicolo-ribaudo merged commit af0a97a into babel:main Feb 13, 2026
55 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the unify-expression-argument-print branch February 13, 2026 13:55
@nicolo-ribaudo nicolo-ribaudo added the PR: Bug Fix 🐛 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: generator PR: Bug Fix 🐛 A type of pull request used for our changelog categories PR: Bug Fix (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