Typescript: how can I assert the type of a variable derived from the data returned from a query if isSuccess
is true?
#8789
Unanswered
lorenzo-dallamuta
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
React-Query can tell Typescript that the result of a query is defined if the
isSuccess
flag is true (withDefinedUseInfiniteQueryResult
), but I can't figure out how to tell Typescript to do the same for a value derived from the query results such as the following.This will yield
'derived' is possibly 'undefined'.ts(18048)
and I'm not really sure how React-Query does the trick with the original query result in the first place.Can I express that a derived values is defined if it is dervied from the query result and
isSuccess
is true without additional null checks?Beta Was this translation helpful? Give feedback.
All reactions