refactor(transformer/class-properties): correct comments (#8636)

This commit is contained in:
overlookmotel 2025-01-21 11:18:02 +00:00
parent dcc1f2bcb3
commit 61d96fde64
2 changed files with 6 additions and 2 deletions

View file

@ -88,8 +88,9 @@ impl<'a> ClassProperties<'a, '_> {
prop: &mut PropertyDefinition<'a>,
ctx: &mut TraverseCtx<'a>,
) {
// Get value, and transform it to replace `this` with reference to class name,
// and transform class fields (`object.#prop`)
// Get value.
// Transform it to replace `this` and references to class name with temp var for class.
// Also transform `super`.
let value = match prop.value.take() {
Some(mut value) => {
self.transform_static_initializer(&mut value, ctx);

View file

@ -155,6 +155,9 @@ impl<'a> ClassProperties<'a, '_> {
/// * Class expression:
/// * `x = class C { static x = C.y; }` -> `var _C; x = (_C = class C {}, _C.x = _C.y, _C)`
/// * `x = class C { static { C.x(); } }` -> `var _C; x = (_C = class C {}, _C.x(), _C)`
/// 3. `super` to transpiled super.
/// * e.g. `super.prop` -> `_superPropGet(_Class, "prop", this)` (in static private method)
/// or `_superPropGet(_Class, "prop", _Class)` (in static property initializer or static block)
///
/// Also:
/// * Update parent `ScopeId` of first level of scopes, if `reparent_scopes == true`.