How could one narrow/split/decompose a possibly discriminated union type?
For example in the following I'd like to get the type with the kind: "bar"
from MyUnion
.
type MyUnion = { kind: "foo", foo: number } | { kind: "bar", bar: string };
// Here I want to somehow get the type { kind: "bar", bar: string } from MyUnion
type Narrowed = NarrowUnion<MyUnion, { kind: "bar" }>;