I am trying to convert some types. I have a "union" type of this kind
interface A {
a: number;
b: string;
}
interface B {
b: number;
c: string[];
}
type Orig = {
$case: 'a';
a: A;
} | {
$case: 'b';
b: B;
}
and I would like to convert it in a more "compact" form, basically removing the $case
type Goal = {
a: A;
} | {
b: B;
}
But I don't want to "write" the Goal
type by hand, I would like to have it as a depended type, maybe using Record
/ Exclude
/ Omit
etc.. but I had no luck :/
Here is the playground with also my tentatives