Skip to content
Discussion options

You must be logged in to vote

I've put your code into typescript playground:

TS 4.6 has a new feature for better Control Flow Analysis for Destructured Discriminated Unions, which is exactly what's kicking in here. Since you are checking for isLoading, and react-query's types are defined as data being undefined if you are in loading state, the compiler now knows that the length check is unnecessary, because data cannot be an array during loading state :)

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@evmartinelli
Comment options

Answer selected by evmartinelli
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