My current interface is structured like this:
export interface Foo {
data?: Foo;
bar?: boolean;
}
Depending on the scenario, data
is used as foo.data.bar
or foo.bar
. However, when implementing the above interface, I encounter the error message:
Property 'bar' does not exist on type 'Foo | undefined'
This error seems odd to me. How can I modify the interface so that data
can carry the types of Foo?