I have this code:
I have copy pasted an image so you can see the type what typescript inherit.
DataStore.query()
returns undefined
or User
. At the end i filter the result with .filter(Boolean)
so that there is no undefined
in it.
Why does typescript still inherit it as (User | undefined)[]
while its not possible that some elements are undefined
?
My expectation is: let users: User[]