Suppose I have a few interfaces A, B, C that implement a common Base.
interface Base {
x: number;
y: number;
z: number;
}
interface A extends Base {
a: true;
}
interface B extends Base {
b: true;
}
interface C extends Base {
c: true;
}
There is a function with if statements:
function foo(arg: A|B|C){
if(arg.a!==undefined){//throws type error
//do stuff for type a
} else if(arg.b !== undefined){//throws type error
//do stuff for type b
} else if(arg.c !== undefined){ //throws type error
//do stuff for type c
}
}
What is the proper way to check if property exists without using any type? Is //@ts-ignore
the only option?