Comment Comment by anamexis 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; } }; parent anamexis 2 years ago
You can already do this:
And this will compile: Whereas this wont: