interface c {
state?: {b: string}
}
const x: c = { state: {b: 'c'}}
console.log(x.state.b)
In the above code, In interface c, state is an optional property.
However when I want to access the property b of the state object whenever it is set, it is giving me this error, Object is possibly 'undefined'. What is the right way to fix this?