Why err.response is typed as any instead of Response? #1460
-
I'm using the const exchanges = [
// ... exchanges
retryExchange(retryOptions)
];
const retryOptions = {
// ...some options
retryIf: (err: CombinedError) => {
if (err.response) {
const response = err.response as Response;
if ([401].includes(response.status)) {
return Logout();
}
}
if (err.networkError) {
showMessage(err.networkError.message)
return err.networkError;
}
},
}; As you can see I need to cast Hence my question: why Is there a better way to write this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
That's because we don't want to type it or guarantee a type because the |
Beta Was this translation helpful? Give feedback.
That's because we don't want to type it or guarantee a type because the
response
may be set to any arrogant that describes the original result of a request, be it for WebSockets or other requests. In other words, because the transport protocol may be swapped out. We didn't want to set this tounknown
for now because that may make it even more confusing, but yea, basically it isn't guaranteed to be aFetchResponse