Latest Results
fix(es/estree)!: fix AST roundtrip bugs and implement missing conversions
**Description:**
Fix several AST conversion bugs and panics across `swc_estree_ast` and `swc_estree_compat` (`babelify` and `swcify`) to improve ESTree/Babel round-trip fidelity:
- **`swc_estree_ast`:**
- Add `#[serde(default)] pub computed: bool` to `ClassPrivateProperty`.
- Add `#[serde(default, rename = "await")] pub is_await: bool` to `ForOfStatement` and wire it through `babelify` and `swcify`.
- Add `LiteralExtra<T>` (`pub extra: Option<...>` with `#[serde(default, skip_serializing_if = "Option::is_none")]`) to `StringLiteral`, `NumericLiteral`, and `BigIntLiteral` to preserve raw literal representations across `babelify` and `swcify`.
- Add `#[serde(default)]` to `StringLiteral::raw` and `ExportSpecifier::export_kind` (deriving `Default` on `ExportKind` with `#[default] Value`).
- **`swc_estree_compat::babelify`:**
- Filter out `ClassMember::Empty` in `Class::babelify` instead of panicking, migrating any attached leading/trailing comments into `ClassBody.base.inner_comments`.
- Populate `computed` flags from `self.key.is_computed()` on `ObjectMethod`, `KeyValueProp`, `KeyValuePatProp`, `ClassMethod`, and `Constructor` (along with `is_static`/`generator`/`is_async` defaults on `Constructor` and `computed: false` on `PrivateMethod`/`PrivateProp`).
- Fix `AssignPatProp::babelify` when a default value is present (`{ x = 1 }`) to emit `ObjectPropVal::Pattern(PatternLike::AssignmentPat(...))` with `shorthand: true` instead of `ObjectPropVal::Expr`, without duplicating comments on the cloned identifier.
- Implement `Babelify` for `OptChainExpr` (`OptionalMemberExpression` and `OptionalCallExpression`), `PropName::BigInt`, and `ModuleExportName::Str`.
- **`swc_estree_compat::swcify`:**
- Implement `Swcify` for `File` and `Program` in `swcify/program.rs`.
- Fix `ClassMethodKind::Method` mapping in `ClassMethod` and `ClassPrivateMethod` (previously mapped to `MethodKind::Getter` instead of `MethodKind::Method`) and read `is_static` from `static_any` on `ClassPrivateProperty`.
- Preserve `computed` property keys via `swcify_object_key` across `ObjectMethod`, `ObjectProperty`, `ClassMethod`, `Constructor`, `ClassProperty`, and `ObjectPatternProp`, while unwrapping non-computed `BigIntLiteral` keys into `PropName::BigInt`.
- Handle computed `MemberExpression` (`arr[i]`, `super[i]`) and `OptionalMemberExpression` (`arr?.[i]`) when `property` deserializes as `Id(Identifier)` instead of panicking on `unreachable!()`.
- Preserve `ObjectMethodKind::Get`/`Set` (`Prop::Getter`/`Prop::Setter`) and shorthand `ObjectProperty` (`Prop::Shorthand`) in `ObjectExprProp::swcify`.
- Fix `ObjectPatternProp::swcify` to preserve default values on shorthand `AssignmentPattern` properties (`{ x = 1 }`) and computed destructuring keys.
**BREAKING CHANGE:**
`swc_estree_ast` structs `ClassPrivateProperty`, `ForOfStatement`, `StringLiteral`, `NumericLiteral`, and `BigIntLiteral` have new public fields (`computed`, `is_await`, and `extra`). All new fields use `#[serde(default)]` so existing JSON inputs continue to deserialize without change, but Rust callers constructing these struct literals directly must initialize the new fields.
**Related issue (if exists):**
N/Agmcsorley-work:estree-upstream-fixes fix(es/estree)!: fix AST roundtrip bugs and implement missing conversions
**Description:**
Fix several AST conversion bugs and panics across `swc_estree_ast` and `swc_estree_compat` (`babelify` and `swcify`) to improve ESTree/Babel round-trip fidelity:
- **`swc_estree_ast`:**
- Add `#[serde(default)] pub computed: bool` to `ClassPrivateProperty`.
- Add `#[serde(default, rename = "await")] pub is_await: bool` to `ForOfStatement` and wire it through `babelify` and `swcify`.
- Add `LiteralExtra<T>` (`pub extra: Option<...>` with `#[serde(default, skip_serializing_if = "Option::is_none")]`) to `StringLiteral`, `NumericLiteral`, and `BigIntLiteral` to preserve raw literal representations across `babelify` and `swcify`.
- Add `#[serde(default)]` to `StringLiteral::raw` and `ExportSpecifier::export_kind` (deriving `Default` on `ExportKind` with `#[default] Value`).
- **`swc_estree_compat::babelify`:**
- Filter out `ClassMember::Empty` in `Class::babelify` instead of panicking, migrating any attached leading/trailing comments into `ClassBody.base.inner_comments`.
- Populate `computed` flags from `self.key.is_computed()` on `ObjectMethod`, `KeyValueProp`, `KeyValuePatProp`, `ClassMethod`, and `Constructor` (along with `is_static`/`generator`/`is_async` defaults on `Constructor` and `computed: false` on `PrivateMethod`/`PrivateProp`).
- Fix `AssignPatProp::babelify` when a default value is present (`{ x = 1 }`) to emit `ObjectPropVal::Pattern(PatternLike::AssignmentPat(...))` with `shorthand: true` instead of `ObjectPropVal::Expr`, without duplicating comments on the cloned identifier.
- Implement `Babelify` for `OptChainExpr` (`OptionalMemberExpression` and `OptionalCallExpression`), `PropName::BigInt`, and `ModuleExportName::Str`.
- **`swc_estree_compat::swcify`:**
- Implement `Swcify` for `File` and `Program` in `swcify/program.rs`.
- Fix `ClassMethodKind::Method` mapping in `ClassMethod` and `ClassPrivateMethod` (previously mapped to `MethodKind::Getter` instead of `MethodKind::Method`) and read `is_static` from `static_any` on `ClassPrivateProperty`.
- Preserve `computed` property keys via `swcify_object_key` across `ObjectMethod`, `ObjectProperty`, `ClassMethod`, `Constructor`, `ClassProperty`, and `ObjectPatternProp`, while unwrapping non-computed `BigIntLiteral` keys into `PropName::BigInt`.
- Handle computed `MemberExpression` (`arr[i]`, `super[i]`) and `OptionalMemberExpression` (`arr?.[i]`) when `property` deserializes as `Id(Identifier)` instead of panicking on `unreachable!()`.
- Preserve `ObjectMethodKind::Get`/`Set` (`Prop::Getter`/`Prop::Setter`) and shorthand `ObjectProperty` (`Prop::Shorthand`) in `ObjectExprProp::swcify`.
- Fix `ObjectPatternProp::swcify` to preserve default values on shorthand `AssignmentPattern` properties (`{ x = 1 }`) and computed destructuring keys.
**BREAKING CHANGE:**
`swc_estree_ast` structs `ClassPrivateProperty`, `ForOfStatement`, `StringLiteral`, `NumericLiteral`, and `BigIntLiteral` have new public fields (`computed`, `is_await`, and `extra`). All new fields use `#[serde(default)]` so existing JSON inputs continue to deserialize without change, but Rust callers constructing these struct literals directly must initialize the new fields.
**Related issue (if exists):**
N/Agmcsorley-work:estree-upstream-fixes Latest Branches
0%
gmcsorley-work:estree-upstream-fixes 0%
Cayan:keep-bool-or-data-deserialize-error 0%
gmcsorley-work:fix-jsx-element-test © 2026 CodSpeed Technology