Skip to content

fix(parser): fix conditional expressions with arrow-function alternates in TS#20356

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/03-13-fix_parser_fix_conditional_expressions_with_arrow-function_alternates_in_ts
Mar 14, 2026
Merged

fix(parser): fix conditional expressions with arrow-function alternates in TS#20356
graphite-app[bot] merged 1 commit intomainfrom
c/03-13-fix_parser_fix_conditional_expressions_with_arrow-function_alternates_in_ts

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Mar 13, 2026

@camc314 camc314 marked this pull request as ready for review March 13, 2026 20:38
Copilot AI review requested due to automatic review settings March 13, 2026 20:38
Copy link
Contributor Author

camc314 commented Mar 13, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of 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.

@github-actions github-actions bot added A-parser Area - Parser C-bug Category - Bug labels Mar 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a TypeScript parsing edge case where conditional expressions involving arrow functions (notably with TS return type annotations) could be parsed incorrectly, and adds a misc coverage case to exercise the scenario.

Changes:

  • Adjusted arrow-function parsing to respect allow_return_type_in_arrow_function when the arrow head is unambiguous.
  • Added a new misc/pass TypeScript coverage case for a conditional expression whose alternate is an arrow function with an explicit return type.
  • Updated coverage snapshots to reflect the additional misc case (and its current semantic-transform-check outcome).

Reviewed changes

Copilot reviewed 1 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/oxc_parser/src/js/arrow.rs Fixes conditional/arrow parsing behavior by honoring the return-type allowance flag for parenthesized arrows.
tasks/coverage/misc/pass/conditional-arrow-alternate-return-type.ts Adds a repro-style misc pass case covering a conditional with an arrow-function alternate using a TS return type.
tasks/coverage/snapshots/parser_misc.snap Snapshot updated for the new misc case count.
tasks/coverage/snapshots/transformer_misc.snap Snapshot updated for the new misc case count.
tasks/coverage/snapshots/codegen_misc.snap Snapshot updated for the new misc case count.
tasks/coverage/snapshots/formatter_misc.snap Snapshot updated for the new misc case count.
tasks/coverage/snapshots/semantic_misc.snap Snapshot updated; now records an additional semantic transform-check mismatch triggered by the new misc case.

You can also share your feedback on Copilot code review. Take the survey.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 13, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing c/03-13-fix_parser_fix_conditional_expressions_with_arrow-function_alternates_in_ts (c0452b9) with main (6eb5b01)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Mar 14, 2026
Copy link
Member

Boshen commented Mar 14, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the c/03-13-fix_parser_fix_conditional_expressions_with_arrow-function_alternates_in_ts branch from c0452b9 to 78c264a Compare March 14, 2026 07:18
@graphite-app graphite-app bot merged commit 78c264a into main Mar 14, 2026
22 checks passed
@graphite-app graphite-app bot deleted the c/03-13-fix_parser_fix_conditional_expressions_with_arrow-function_alternates_in_ts branch March 14, 2026 07:29
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 14, 2026
Boshen added a commit that referenced this pull request Mar 14, 2026
### 🚀 Features

- e7163b6 ecmascript: Add known-globals to side-effect-free property
reads (#20212) (Dunqing)
- 139ab68 ecmascript: Add `property_write_side_effects` to
`MayHaveSideEffectsContext` (#20217) (Dunqing)

### 🐛 Bug Fixes

- 78c264a parser: Fix conditional expressions with arrow-function
alternates in TS (#20356) (camc314)
- 5c97b14 minifier: Recognize object spread of object literals as
side-effect-free (#20299) (Boshen)
- 1ff5c1d transformer/typescript: Rewrite extensions in dynamic
`import()` expressions (#20121) (Sverre Johansen)
- 1c07b3b diagnostics: Handle `WouldBlock` in stdout writes to prevent
panic (#20295) (Boshen)
- ade14d4 ecmascript: Enhance side-effect detection for classes,
TypedArrays, computed members, and spread (#20213) (Dunqing)

### ⚡ Performance

- 5474d0a semantic: V8-style walk-up reference resolution (#20292)
(Boshen)

### 📚 Documentation

- e4aa5b5 parser/napi, linter/plugins: Add JSDoc comments to raw
transfer constants (#20286) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrect parsing of ternary operators

3 participants