Skip to content

Fix optional chain tagged template output - #18201

Closed
mameikagou wants to merge 1 commit into
babel:mainfrom
mameikagou:codex/fix-optional-chain-template-tag
Closed

mameikagou wants to merge 1 commit into
babel:mainfrom
mameikagou:codex/fix-optional-chain-template-tag

Conversation

@mameikagou

Copy link
Copy Markdown

This pull request description was generated with LLM assistance.

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

An optional member or call expression is not valid as an unparenthesized tagged-template tag. The generator currently drops the original parentheses and can emit syntax that cannot be parsed.

The generator now keeps parentheses when an optional expression is the tag of a TaggedTemplateExpression, and this is obviously going to solve the problem by preserving valid grammar without affecting unrelated expression positions.

A regression fixture covers the reported input. The Babel generator test suites pass.

@github-actions

Copy link
Copy Markdown

❌ Automation signals

Activity patterns show signs of automation.

View full analysis →

This is an automated analysis by AgentScan

@babel-bot

Copy link
Copy Markdown
Collaborator

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

@pkg-pr-new

pkg-pr-new Bot commented Aug 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: 390a4a3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@babel/generator produce syntactically incorrect code on tags + opt chains in parens

3 participants