mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
feat(ast): serialize BindingPattern to estree (#2610)
This commit is contained in:
parent
97aa9cfd54
commit
1db307abbf
1 changed files with 7 additions and 2 deletions
|
|
@ -1595,9 +1595,15 @@ pub struct DebuggerStatement {
|
||||||
/// Destructuring Binding Patterns
|
/// Destructuring Binding Patterns
|
||||||
/// * <https://tc39.es/ecma262/#prod-BindingPattern>
|
/// * <https://tc39.es/ecma262/#prod-BindingPattern>
|
||||||
#[derive(Debug, Hash)]
|
#[derive(Debug, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))]
|
#[cfg_attr(feature = "serde", derive(Serialize), serde(rename_all = "camelCase"))]
|
||||||
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
|
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
|
||||||
pub struct BindingPattern<'a> {
|
pub struct BindingPattern<'a> {
|
||||||
|
// Flatten the attributes because estree has no `BindingPattern`
|
||||||
|
#[cfg_attr(feature = "serde", serde(flatten))]
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "serde", feature = "wasm"),
|
||||||
|
tsify(type = "(BindingIdentifier | ObjectPattern | ArrayPattern | AssignmentPattern)")
|
||||||
|
)]
|
||||||
pub kind: BindingPatternKind<'a>,
|
pub kind: BindingPatternKind<'a>,
|
||||||
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
|
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
|
||||||
pub optional: bool,
|
pub optional: bool,
|
||||||
|
|
@ -1611,7 +1617,6 @@ impl<'a> BindingPattern<'a> {
|
||||||
|
|
||||||
#[derive(Debug, Hash)]
|
#[derive(Debug, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize), serde(untagged))]
|
#[cfg_attr(feature = "serde", derive(Serialize), serde(untagged))]
|
||||||
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
|
|
||||||
pub enum BindingPatternKind<'a> {
|
pub enum BindingPatternKind<'a> {
|
||||||
/// `const a = 1`
|
/// `const a = 1`
|
||||||
BindingIdentifier(Box<'a, BindingIdentifier<'a>>),
|
BindingIdentifier(Box<'a, BindingIdentifier<'a>>),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue