Skip to content

Commit

Permalink
docs(transformer/class-properties): clarify doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Dec 15, 2024
1 parent 88a3159 commit 9d101ac
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions crates/oxc_transformer/src/es2022/class_properties/prop_decl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::{
// Instance properties
impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
/// Convert instance property to initialization expression.
/// Property `foo = 123;` -> Expression `this.foo = 123` or `_defineProperty(this, "foo", 123)`.
/// Property `prop = 123;` -> Expression `this.prop = 123` or `_defineProperty(this, "prop", 123)`.
pub(super) fn convert_instance_property(
&mut self,
prop: &mut PropertyDefinition<'a>,
Expand Down Expand Up @@ -82,14 +82,14 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
// Static properties
impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
/// Convert static property to initialization expression.
/// Property `static foo = 123;` -> Expression `C.foo = 123` or `_defineProperty(C, "foo", 123)`.
/// Property `static prop = 123;` -> Expression `C.prop = 123` or `_defineProperty(C, "prop", 123)`.
pub(super) fn convert_static_property(
&mut self,
prop: &mut PropertyDefinition<'a>,
ctx: &mut TraverseCtx<'a>,
) {
// Get value, and transform it to replace `this` with reference to class name,
// and transform class property accesses (`object.#prop`)
// and transform class fields (`object.#prop`)
let value = match &mut prop.value {
Some(value) => {
self.transform_static_initializer(value, ctx);
Expand Down Expand Up @@ -201,7 +201,7 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {

// Used for both instance and static properties
impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
/// `assignee.foo = value` or `_defineProperty(assignee, "foo", value)`
/// `assignee.prop = value` or `_defineProperty(assignee, "prop", value)`
fn create_init_assignment(
&mut self,
prop: &mut PropertyDefinition<'a>,
Expand All @@ -211,15 +211,15 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
ctx: &mut TraverseCtx<'a>,
) -> Expression<'a> {
if self.set_public_class_fields {
// `assignee.foo = value`
// `assignee.prop = value`
self.create_init_assignment_loose(prop, value, assignee, is_static, ctx)
} else {
// `_defineProperty(assignee, "foo", value)`
// `_defineProperty(assignee, "prop", value)`
self.create_init_assignment_not_loose(prop, value, assignee, ctx)
}
}

/// `this.foo = value` or `_Class.foo = value`
/// `this.prop = value` or `_Class.prop = value`
fn create_init_assignment_loose(
&mut self,
prop: &mut PropertyDefinition<'a>,
Expand Down Expand Up @@ -261,7 +261,7 @@ impl<'a, 'ctx> ClassProperties<'a, 'ctx> {
)
}

/// `_defineProperty(this, "foo", value)` or `_defineProperty(_Class, "foo", value)`
/// `_defineProperty(this, "prop", value)` or `_defineProperty(_Class, "prop", value)`
fn create_init_assignment_not_loose(
&mut self,
prop: &mut PropertyDefinition<'a>,
Expand Down

0 comments on commit 9d101ac

Please sign in to comment.