mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-02 08:35:07 +08:00
* Expand static Effect support across common APIs * Preserve compiler parity across expanded Effect patterns * Fix compiler regressions exposed by Effect coverage * Bound shared type conversion traversal * Clarify conversion contracts and tidy fixtures * Run every Effect fixture in CI shards * Preserve inferred array assignments in concurrent Effect programs * Record inferred array fixture compiler ordering
22 lines
768 B
JavaScript
22 lines
768 B
JavaScript
function Base(props) { Object.assign(this, props); }
|
|
const makeClass = ({ Base, label }) => {
|
|
const key = Symbol.for(label);
|
|
const Result = class extends Base {
|
|
constructor(props) { super(props); }
|
|
get [key]() { return label; }
|
|
};
|
|
Object.defineProperty(Result.prototype, "describe", {
|
|
value() { return label + ":" + this.value; },
|
|
configurable: true,
|
|
writable: true,
|
|
});
|
|
return Result;
|
|
};
|
|
const factory = label => () => makeClass({ Base, label });
|
|
class First extends factory("first")() {}
|
|
class Second extends factory("second")() {}
|
|
const first = new First({ value: 42 });
|
|
const second = new Second({ value: 7 });
|
|
console.log(first.describe(), second.describe());
|
|
console.log(first[Symbol.for("first")], second[Symbol.for("second")]);
|