You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my opinion, I think if isLoading is false that means fetcher is executed finished, and if error is null, that means the executed result is successful, so data is must not undefined.
But I see the TypeScript report the data may be undefined in this case, is there any way to optimize the logic of typing narrow? Actually, I think in this condition, SWR should assert the data must not be undefined, is this an issue that can be improved?
cw1997
changed the title
SWR should assert the data must not be undefined if isLoading is false and error is null
SWR should assert the data not be undefined if isLoading is false and error is null
Apr 30, 2024
The sample code at here:
In my opinion, I think if
isLoading
is false that means fetcher is executed finished, and iferror
is null, that means the executed result is successful, so data is must not undefined.But I see the TypeScript report the data may be undefined in this case, is there any way to optimize the logic of typing narrow? Actually, I think in this condition, SWR should assert the data must not be undefined, is this an issue that can be improved?
Thank you very much!
Originally posted by @cw1997 in #2942
The text was updated successfully, but these errors were encountered: