given the following example:
type V0Input = {
version: '0'
};
type V1Input = {
version: '1'
}
type AnyInput = V0Input | V1Input;
type V0Output = {
a: string
}
type V1Output = {
b: string
}
type Ret<I> = I extends V0Input ? V0Output : V1Output
const fn = <I extends AnyInput>(i: I): Ret<I> => i.version === '0' ?
{a: ''} as Ret<I> :
{b: ''} as Ret<I>
;
Did anyone found out a way to remove those casts? I've started using something like that without casts (taking lambda parametrized by outer I), but it turns out that my method doesn't work for all kind of objects.