Skip to content

Type narrowing is lost when use selectFromResult #3015

Answered by phryneas
alagunoff asked this question in Q&A
Discussion options

You must be logged in to vote

You are replacing the return type of the RTKQ query hook with your own (in this case implicit) type.
If you want type behaviour like that, you will have to create a type with that behaviour and explicitly return that.

E.g.

type MyType = { isVaultBeingFetched: true, vault: undefined } | { isVaultBeingFetched: false, vault: SomeVaultType }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by alagunoff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants