Can you say more about natively supporting discriminated unions?
You can already do this:
type MyUnion = { type: "foo"; foo: string } | { type: "bar"; bar: string };
And this will compile: (u: MyUnion) => {
switch (u.type) {
case "foo":
return u.foo;
case "bar":
return u.bar;
}
};
Whereas this wont: (u: MyUnion) => {
switch (u.type) {
case "foo":
return u.bar;
case "bar":
return u.foo;
}
};