Skip to content

fix(estree): Use consistent field order in serialization#11385

Merged
overlookmotel merged 2 commits intomainfrom
f/estree-field-order
Jun 2, 2025
Merged

fix(estree): Use consistent field order in serialization#11385
overlookmotel merged 2 commits intomainfrom
f/estree-field-order

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented May 30, 2025

Part of #9705 , follow up #11362

This change will generate the same AST shapes in all locations, regardless of visitor-keys.

Copilot AI review requested due to automatic review settings May 30, 2025 04:04
@graphite-app
Copy link
Contributor

graphite-app bot commented May 30, 2025

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 hot fixes, skip the queue and merge this PR next

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.

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

This PR ensures that the field order in ESTree node serialization is consistent for both TypeScript and JavaScript ASTs, supporting fixes for issues #9705 and #11362.

  • Reorders fields in TSTypeNameIdentifierReference and TSTypeNameAsMemberExpression in ts.rs to align with the established serialization pattern.
  • Adjusts field placement in js.rs, including proper conditional inclusion of TS-specific fields such as decorators for RestElement, FormalParametersRest, ArrowFunctionExpressionBody, and AssignmentTargetPropertyIdentifierInit.

Reviewed Changes

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

File Description
crates/oxc_ast/src/serialize/ts.rs Reordered the placement of "computed" and "optional" fields to achieve a consistent serialization order.
crates/oxc_ast/src/serialize/js.rs Updated field ordering, especially around conditional TS sections (decorators, argument), for consistency in output.

@github-actions github-actions bot added A-ast Area - AST C-bug Category - Bug labels May 30, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented May 30, 2025

CodSpeed Instrumentation Performance Report

Merging #11385 will not alter performance

Comparing f/estree-field-order (86f95a6) with main (1cd8b9c)

Summary

✅ 38 untouched benchmarks

@Boshen Boshen requested a review from overlookmotel May 30, 2025 05:39
Copy link
Member

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

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

Great! Thank you.

@overlookmotel overlookmotel merged commit ec4fc83 into main Jun 2, 2025
24 checks passed
@overlookmotel overlookmotel deleted the f/estree-field-order branch June 2, 2025 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants