Imagine a scenario where there is a choice between multiple interfaces
interface a {x:string}
interface b {y:string}
interface c {z:string}
type all = a | b | c
Now, consider an object fulfilling all
by being of type c
When you try to access the property 'z' by calling:
if (obj.hasOwnProperty('z')) {
return obj.z
}
You encounter a compilation error:
The code fails to compile because:
Property 'z' does not exist on type 'a'.
What would be your approach to resolve this issue?