Skip to content

Commit

Permalink
fix(ast): estree compat Property (#8974)
Browse files Browse the repository at this point in the history
Part of #2854

```diff
-Positive Passed: 16040/44293 (36.21%)
+Positive Passed: 28924/44293 (65.30%)
```
  • Loading branch information
hi-ogawa committed Feb 9, 2025
1 parent 801d78e commit 2ee1d6c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12,889 deletions.
6 changes: 6 additions & 0 deletions crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ pub enum ObjectPropertyKind<'a> {
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
#[estree(rename = "Property")]
pub struct ObjectProperty<'a> {
pub span: Span,
pub kind: PropertyKind,
Expand Down Expand Up @@ -1476,6 +1477,11 @@ pub struct ObjectPattern<'a> {
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
#[estree(
rename = "Property",
add_fields(kind = "\"init\"", method = false),
add_ts = "kind: \"init\"; method: false"
)]
pub struct BindingProperty<'a> {
pub span: Span,
pub key: PropertyKey<'a>,
Expand Down
6 changes: 4 additions & 2 deletions crates/oxc_ast/src/generated/derive_estree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl Serialize for ObjectPropertyKind<'_> {
impl Serialize for ObjectProperty<'_> {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serializer.serialize_map(None)?;
map.serialize_entry("type", "ObjectProperty")?;
map.serialize_entry("type", "Property")?;
map.serialize_entry("start", &self.span.start)?;
map.serialize_entry("end", &self.span.end)?;
map.serialize_entry("kind", &self.kind)?;
Expand Down Expand Up @@ -1287,13 +1287,15 @@ impl Serialize for ObjectPattern<'_> {
impl Serialize for BindingProperty<'_> {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serializer.serialize_map(None)?;
map.serialize_entry("type", "BindingProperty")?;
map.serialize_entry("type", "Property")?;
map.serialize_entry("start", &self.span.start)?;
map.serialize_entry("end", &self.span.end)?;
map.serialize_entry("key", &self.key)?;
map.serialize_entry("value", &self.value)?;
map.serialize_entry("shorthand", &self.shorthand)?;
map.serialize_entry("computed", &self.computed)?;
map.serialize_entry("kind", &"init")?;
map.serialize_entry("method", &false)?;
map.end()
}
}
Expand Down
6 changes: 4 additions & 2 deletions npm/oxc-types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export interface ObjectExpression extends Span {
export type ObjectPropertyKind = ObjectProperty | SpreadElement;

export interface ObjectProperty extends Span {
type: 'ObjectProperty';
type: 'Property';
kind: PropertyKind;
key: PropertyKey;
value: Expression;
Expand Down Expand Up @@ -513,11 +513,13 @@ export interface ObjectPattern extends Span {
}

export interface BindingProperty extends Span {
type: 'BindingProperty';
type: 'Property';
key: PropertyKey;
value: BindingPattern;
shorthand: boolean;
computed: boolean;
kind: 'init';
method: false;
}

export interface ArrayPattern extends Span {
Expand Down
Loading

0 comments on commit 2ee1d6c

Please sign in to comment.