-
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
Structs / classes do not work with inheritance combined with Storage collections.
import { Datex, property } from "unyt_core/datex.ts";
import { inferType, StorageSet } from 'unyt_core/datex_all.ts';
const C = 0;
{ // Classes
@sync class A {
@property a!: number;
construct() {
this.a = 42;
}
}
@sync class B extends A {
@property b!: number;
construct() {
super.construct();
this.b = 69;
}
}
const list = eternalVar("tmp1-"+C) ?? $$(new StorageSet<A>());
if (await list.getSize() === 0) {
await list.add(new A());
await list.add(new B());
}
for await (const entry of list) {
console.log(entry.a, entry.b)
}
console.log("")
}
{ // Structs
const A = struct(
class A {
@property a!: number;
construct() {
this.a = 42;
}
}
)
type A = inferType<typeof A>;
const B = struct(
class B extends A {
@property b!: number;
construct() {
super.construct();
this.b = 69;
}
}
)
type B = inferType<typeof B>;
const list = eternalVar("tmp2-"+C) ?? $$(new StorageSet<A>());
if (await list.getSize() === 0) {
await list.add(new A());
await list.add(new B());
}
for await (const entry of list) {
console.log(entry.a, entry.b)
}
}Reactions are currently unavailable