Let's say I have few interfaces A, B, C implementing 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;
}
And 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
}
}
How to correctly check if property exists? I don't wan't to use any type. Is //@ts-ignore
only option?