I suspect you can adjust your approach a little and use something along the lines of the example here:
https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guardshttps://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates
function isFish(pet: Fish | Bird): pet is Fish {
return (pet as Fish).swim !== undefined;
}