MasatoDev / boostest

14 stars 0 forks source link

Support class arguments other than `BindingPatternKind::BindingIdentifier` #4

Closed MasatoDev closed 1 month ago

MasatoDev commented 2 months ago

Currently only BindingPatternKind::BindingIdentifier is supported for handling class arguments.

pub enum BindingPatternKind<'a> {
    /// `const a = 1`
    BindingIdentifier(Box<'a, BindingIdentifier<'a>>),
    /// `const {a} = 1`
    ObjectPattern(Box<'a, ObjectPattern<'a>>),
    /// `const [a] = 1`
    ArrayPattern(Box<'a, ArrayPattern<'a>>),
    /// A defaulted binding pattern, i.e.:
    /// `const {a = 1} = 1`
    /// the assignment pattern is `a = 1`
    /// it has an inner left that has a BindingIdentifier
    AssignmentPattern(Box<'a, AssignmentPattern<'a>>),
}

However, in order to support the following notations, ObjectPattern and others must also be supported.

class ClassObj {
  name: string;
  chips: ComplexInterfaceChips;

  constructor(
    { name, chips }: { name: string; chips: ComplexInterfaceChips },
  ) {
    this.name = name;
    this.chips = chips;
  }
}

export default ClassObj;