I have an interface that looks like
export interface Foo {
data?: Foo;
bar?: boolean;
}
In some cases, the data is being used as foo.data.bar and in other cases foo.bar. When I use the interface above I'm seeing:
Property 'bar' does not exist on type 'Foo | undefined'
This feels kind of weird, but how can I adjust this so that data could have Foo's types?
datacan beundefined, so you have to check before access it