// TypeScript Version
type _TypeA = {
kind: "a";
a: number;
};
type _TypeB = {
kind: "b";
b: string;
};
const ts = new Map<number, _TypeA | _TypeB>();
{
const e = ts.get(1)!;
switch (e.kind) {
case "a":
alert(e.a);
break;
case "b":
alert(e.b);
break;
}
}
// TypeScript Version
type _TypeA = {
kind: "a";
a: number;
};
type _TypeB = {
kind: "b";
b: string;
};
const ts = new Map<number, _TypeA | _TypeB>();
{
const e = ts.get(1)!;
switch (e.kind) {
case "a":
alert(e.a);
break;
case "b":
alert(e.b);
break;
}
}