Files
scriptc/tests/corpus/js-super-accessor-initialization.js
Chris Tate a07998f667 Expand static three.js workflows and host integration (#621)
* Expand static three.js workflows and host integration

* Preserve JavaScript class state in static three.js workflows

* Preserve inferred JavaScript behavior across static workflows

* Preserve inferred callables and native compatibility boundaries

* Retain annotated JavaScript factory exports and bootstrap-safe call spreads

* Preserve Buffer and child callback identities in static packages

* Clarify JavaScript symbol spread support
2026-10-02 19:56:34 -05:00

34 lines
1.1 KiB
JavaScript

class Base {
constructor(value) { this.value = value; }
}
class Child extends Base {
constructor(value) {
super(value);
/** @type {?Base} */
this.reference = null;
this.ready = true;
this.count = 2;
this._value = value;
}
// @ts-expect-error JavaScript permits the base constructor to invoke this accessor.
set value(value) {
console.log("before", this.reference, this.ready, this.count);
if (this.reference) this.reference.value = value;
else this._value = value;
}
get value() { return this.reference ? this.reference.value : this._value; }
}
const child = new Child(3);
console.log("after", child.value, child.reference, child.ready, child.count);
child.value = 4;
console.log("updated", child.value);
class DeclaredChild extends Base {
ready = true;
["count"] = 2;
// @ts-expect-error JavaScript permits the base constructor to invoke this accessor.
set value(value) { console.log("declared before", this.ready, this.count); this._value = value; }
get value() { return this._value; }
}
const declared = new DeclaredChild(5);
console.log("declared after", declared.value, declared.ready, declared.count);