Below is the code I've been working on.
function DD(x: { y: string } | {}) {
if (x.y) {//error
console.log("DD jingo");
}
}
An error is displayed stating "The property "y" does not exist in the type "{} | {y: string;}". The property "y" does not exist in the type "{}".
I am still learning TypeScript. Can someone guide me on how to specify that X should be able to accept both an empty object and {y: string}?