fix(codegen): don't inject parenthesis in optional chaining within new expressions#14170
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #14170 will not alter performanceComparing Summary
Footnotes |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a codegen issue where parentheses were incorrectly being injected around optional chaining expressions within new expressions. The fix ensures that optional chaining operators (?.) are properly preserved without unwanted parentheses when used inside function or class constructors invoked with new.
- Updates context handling for
FunctionandClassexpressions to disable call parentheses injection - Adds comprehensive test cases covering both function and class expressions with optional chaining
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_codegen/src/gen.rs | Modified context handling for Function and Class expressions to prevent unwanted parentheses injection |
| crates/oxc_codegen/tests/integration/js.rs | Added test cases verifying optional chaining works correctly within new expressions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Boshen
left a comment
There was a problem hiding this comment.
It seems like this is controlled by hasNonOptionalChainParent in esbuild. Our codegen should align with esbuild exactly.
Merge activity
|
d113b09 to
aa927ab
Compare

fixes #14127