Typescript optional chaining error: Expression expected.ts(1109) : <p>I am trying to do optional chaining in Typescript + React Native.</p>

<p>Let's say I have the following interfaces:</p>

<pre><code>interface Bar {
  y: number
}

interface Foo {
  x?: Bar
}
</code></pre>

<p>and I try to run the following:</p>

<pre><code> const test: Foo = {x: {y: 3}};
 console.log(test.x?.y);
</code></pre>

<p>VSCode will show an error under the <code>?.</code> saying the following: <em>Expression expected.ts(1109)</em> </p>

<p>Do you have any idea why this is happening or how should I fix it? Thanks.</p>
