Even with optional variable flag still getting 'result?.expand' is possibly 'undefined'.ts(18048)

19 Views Asked by At

I'm using PocketBase and Svelte to code a small project. In vscode I am getting error syntax highlighting on this code. It is working and in other discussions it sayd the result?.expand should fix this.

enter image description here

1

There are 1 best solutions below

0
Darshan Patel On

this errors are for .winner and .runnerUp , you need to add ? before every . access to make it work

result?.expand?.winner?.first_name
result?.expand?.runnerUp?.first_name