Files
Chris Tate 306251e3df feat(compiler): preserve native type refinements for self-hosting
- Preserve class identity and member storage through interface and intersection refinements.
- Replace TypeScript runtime enum imports with pinned native constants and name lookups.
- Use concrete type predicates in the native semantic client.
2026-09-28 08:12:06 -05:00

26 lines
735 B
TypeScript

import { inspect, choose } from "./functions.js";
class Box<T> {
value: T;
constructor(value: T) { this.value = value; }
get current(): T { return this.value; }
replace(value: T): void { this.value = value; }
}
interface BoxView<T> extends Box<T> {}
interface DeepBox<T> extends BoxView<T> {}
const direct = new Box(inspect);
direct.value(1, 2);
const saved = direct.current;
saved(3);
const view: DeepBox<typeof inspect> = direct;
const fromView = view.current;
fromView(4, 5);
view.replace(inspect);
view.value();
const chooser: DeepBox<typeof choose> = new Box(choose);
const chooseFromView = chooser.current;
console.log(chooseFromView(7), chooser.value(8, 9));
console.log(chooseFromView(undefined), chooseFromView());