mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-21 05:50:55 +08:00
- Compile initialized Symbol() and Symbol.for() fields, including inherited OpenTUI brands. - Share registry-key storage across modules and keep symbol slots out of string-keyed enumeration. - Refuse unstable keys and unsupported symbol-field copies.
16 lines
420 B
TypeScript
16 lines
420 B
TypeScript
const brand: unique symbol = Symbol.for("scriptc.typed.brand");
|
|
const text: unique symbol = Symbol("text");
|
|
|
|
class Typed {
|
|
[brand]: boolean = true;
|
|
[text]: string | undefined = undefined;
|
|
read(): boolean {
|
|
return this[brand];
|
|
}
|
|
}
|
|
const typed = new Typed();
|
|
console.log(typed[brand], typed[text], typed.read());
|
|
typed[brand] = false;
|
|
typed[text] = "set";
|
|
console.log(typed[brand], typed[text], typed.read());
|