Files
scriptc/tests/corpus/2793-union-conversion-identity-capture.ts
Chris Tate 94fd361b54 Implement sparse native arrays and missing-value parity (#297)
Represent ordinary JavaScript arrays with hole, value, and explicit-undefined states; add sparse side storage and carry missing values through the frontend, native backends, runtime, and Node-facing consumers.
2026-09-12 22:39:07 -05:00

24 lines
658 B
TypeScript

class Item {
name: string;
constructor(name: string) {
this.name = name;
}
}
function same(left: Item | undefined, right: Item | null): boolean {
return left === right;
}
const item = new Item("x");
console.log("identity", same(item, item), same(undefined, null));
function describe(value: number | symbol | undefined): string {
if (typeof value === "undefined") return "undefined";
if (typeof value !== "symbol") return "number=" + value;
return value.toString();
}
console.log("convert", describe(7), describe(Symbol("s")), describe(undefined));
const { groups } = /(?<word>\w+)/.exec("hello")!;
console.log("capture", groups!.word);