Skip to content

Commit

Permalink
refactor(transformer/class-properties): TODO comments for future opti…
Browse files Browse the repository at this point in the history
…mizations
  • Loading branch information
overlookmotel committed Dec 7, 2024
1 parent 6cc51be commit 6867567
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ impl<'a, 'c> ConstructorParamsSuperReplacer<'a, 'c> {
// TODO(improve-on-babel): When not in loose mode, inits are `_defineProperty(this, propName, value)`.
// `_defineProperty` returns `this`, so last statement could be `return _defineProperty(this, propName, value)`,
// rather than an additional `return this` statement.
// Actually this wouldn't work at present, as `_classPrivateFieldInitSpec(this, _prop, value)`
// does not return `this`. We could alter it so it does when we have our own helper package.
fn create_super_func(inits: Vec<Expression<'a>>, ctx: &mut TraverseCtx<'a>) -> Expression<'a> {
let outer_scope_id = ctx.current_scope_id();
let super_func_scope_id = ctx.scopes_mut().add_scope(
Expand Down Expand Up @@ -534,6 +536,8 @@ impl<'a, 'c> ConstructorBodyInitsInserter<'a, 'c> {
// TODO(improve-on-babel): When not in loose mode, inits are `_defineProperty(this, propName, value)`.
// `_defineProperty` returns `this`, so last statement could be `return _defineProperty(this, propName, value)`,
// rather than an additional `return this` statement.
// Actually this wouldn't work at present, as `_classPrivateFieldInitSpec(this, _prop, value)`
// does not return `this`. We could alter it so it does when we have our own helper package.
let super_call = create_super_call(&args_binding, ctx);
let this_expr = ctx.ast.expression_this(SPAN);
let body_exprs = ctx.ast.expression_sequence(
Expand Down

0 comments on commit 6867567

Please sign in to comment.