Skip to content

Commit 760188e

Browse files
fix(ast/estree): Fix BindingProperty (#10193)
Adds the `optional` field to the Estree serialiser for the `BindingProperty` node. Part of our broader work to align our AST's ESTree output with that of TS-ESLint's. Relates to #9705 --------- Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
1 parent 5525206 commit 760188e

File tree

5 files changed

+6
-182
lines changed

5 files changed

+6
-182
lines changed

crates/oxc_ast/src/ast/js.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,8 +1583,8 @@ pub struct ObjectPattern<'a> {
15831583
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
15841584
#[estree(
15851585
rename = "Property",
1586-
add_fields(method = False, kind = Init),
1587-
field_order(span, method, shorthand, computed, key, value, kind),
1586+
add_fields(method = False, kind = Init, optional = TsFalse),
1587+
field_order(span, method, shorthand, computed, key, value, kind, optional),
15881588
)]
15891589
pub struct BindingProperty<'a> {
15901590
pub span: Span,

crates/oxc_ast/src/generated/derive_estree.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,7 @@ impl ESTree for BindingProperty<'_> {
13021302
state.serialize_field("key", &self.key);
13031303
state.serialize_field("value", &self.value);
13041304
state.serialize_field("kind", &crate::serialize::Init(self));
1305+
state.serialize_ts_field("optional", &crate::serialize::TsFalse(self));
13051306
state.end();
13061307
}
13071308
}

napi/parser/deserialize-ts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ function deserializeBindingProperty(pos) {
757757
key: deserializePropertyKey(pos + 8),
758758
value: deserializeBindingPattern(pos + 24),
759759
kind: 'init',
760+
optional: false,
760761
};
761762
}
762763

npm/oxc-types/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ export interface BindingProperty extends Span {
534534
key: PropertyKey;
535535
value: BindingPattern;
536536
kind: 'init';
537+
optional?: false;
537538
}
538539

539540
export interface ArrayPattern extends Span {

0 commit comments

Comments
 (0)