Conditional returning, returning wrong types
Condtionals in returning are not returning the correct types.
10 Replies
can you share you tsconfig?
https://drizzle.run/qo0r3rrcoclg9owbazwjiiy5
Drizzle Run
Conditional returning - Drizzle Run
But even if I can't reproduce the
undefined
, I note that the return type does not keep the 'optional' part of the returning objtsconfig -
Yeah this seems wrong
The
undefined
inference is due to noUncheckedIndexedAccess
. Without it it should be "good"
You may want this option in TS, but the drawback is that now you have to check that array items are not undefined
And for that I think it is a Drizzle bug because the object passed to returning
is correctly infered(from one of my projects)
Yeah not too worried about the undefined thing, was just playing around and noticed some weird behaviour. But in the case of a conditional returning, the return type is a drizzle issue?
for this no
but for the missing optional flag (z?: number) yes I guess
I missed your 2nd screenshot sorry, I am looking at it
2nd screenshot is bug yeah. Pretty sure it is related
I'm more just worried about the type saying something exists, when it may or may not exist 🥶
I will return everything and forget everything you have discovered 😂
I will try to open an issue about that, thx!