-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
oxc-project/oxc#7175 demonstrates that it's easy to confuse a function which is the property value of an object expression with an object method. i.e. to conflate these 2:
obj = {
foo() {}
};
obj = {
foo: function() {}
};We could avoid this confusing by changing ObjectPropertyKind to have separate variants for methods, getters and setters.
Current:
pub enum ObjectPropertyKind<'a> {
// This variant can be either a property or a method
ObjectProperty(Box<'a, ObjectProperty<'a>>),
SpreadProperty(Box<'a, SpreadElement<'a>>),
}Proposed:
pub enum ObjectPropertyKind<'a> {
ObjectProperty(Box<'a, ObjectProperty<'a>>),
SpreadProperty(Box<'a, SpreadElement<'a>>),
Method(Box<'a, ObjectMethod<'a>>),
Getter(Box<'a, ObjectMethod<'a>>),
Setter(Box<'a, ObjectMethod<'a>>),
}
pub struct ObjectProperty<'a> {
pub span: Span,
// pub kind: PropertyKind, <-- removed
pub key: PropertyKey<'a>,
pub value: Expression<'a>,
pub init: Option<Expression<'a>>, // for `CoverInitializedName`
// pub method: bool, <-- removed
pub shorthand: bool,
pub computed: bool,
}
pub struct ObjectMethod<'a> {
pub span: Span,
pub key: PropertyKey<'a>,
pub func: Function<'a>,
pub computed: bool,
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackPriority
None yet