I am trying to do optional chaining in Typescript + React Native.
Let's say I have the following interfaces:
interface Bar {
y: number
}
interface Foo {
x?: Bar
}
and I try to run the following:
const test: Foo = {x: {y: 3}};
console.log(test.x?.y);
VSCode will show an error under the ?.
saying the following: Expression expected.ts(1109)
Do you have any idea why this is happening or how should I fix it? Thanks.