add test, fix more stuff

pull/16051/head
ComputerGuy 4 months ago
parent 7e0a81d102
commit 152fe5019b

@ -49,11 +49,6 @@ function build_assignment(operator, left, right, context) {
/** @type {Expression} */ (context.visit(right))
);
}
} else if (field && (field.type === '$derived' || field.type === '$derived.by')) {
let value = /** @type {Expression} */ (
context.visit(build_assignment_value(operator, left, right))
);
return b.call(b.member(b.this, name), value);
}
}

@ -5,7 +5,7 @@ export default function Class_state_field_constructor_assignment($$anchor, $$pro
$.push($$props, true);
class Foo {
#a = $.state();
#a = $.state(0);
get a() {
return $.get(this.#a);
@ -16,10 +16,31 @@ export default function Class_state_field_constructor_assignment($$anchor, $$pro
}
#b = $.state();
#foo = $.derived(() => ({ bar: this.a * 2 }));
get foo() {
return $.get(this.#foo);
}
set foo(value) {
$.set(this.#foo, value);
}
#bar = $.derived(() => ({ baz: this.foo }));
get bar() {
return $.get(this.#bar);
}
set bar(value) {
$.set(this.#bar, value);
}
constructor() {
this.a = 1;
$.set(this.#b, 2);
this.foo.bar = 3;
this.bar = 4;
}
}

@ -4,12 +4,33 @@ export default function Class_state_field_constructor_assignment($$payload, $$pr
$.push();
class Foo {
a;
a = 0;
#b;
#foo = $.derived(() => ({ bar: this.a * 2 }));
get foo() {
return this.#foo();
}
set foo($$value) {
return this.#foo($$value);
}
#bar = $.derived(() => ({ baz: this.foo }));
get bar() {
return this.#bar();
}
set bar($$value) {
return this.#bar($$value);
}
constructor() {
this.a = 1;
this.#b = 2;
this.foo.bar = 3;
this.bar = 4;
}
}

@ -1,11 +1,14 @@
<script>
class Foo {
a = $state();
a = $state(0);
#b = $state();
foo = $derived({ bar: this.a * 2 });
bar = $derived({ baz: this.foo });
constructor() {
this.a = 1;
this.#b = 2;
this.foo.bar = 3;
this.bar = 4;
}
}
</script>

Loading…
Cancel
Save