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
Hi.
When I use the transformErrorResponse I can provide custom error type returned from this method.
But it still doesn't infered when the mutation is called. So the result of calling mutation would still be { data: ResultType } | { error: FetchBaseQueryError | SerializedError } while it should be something like ReturnType<typeof transformErrorResponse>.
Yes, I can write a guard for it, but this guard will allow a type other than my custom.
if(isMyCustomError(result.error)){// handle typed error}else{// here result.error should have `never` type, but it won't}
Also, I can cast the type (like, result.error as MyCustomError) but this not a good solution.
So, my question here: why the type in not infered from tranformErrorResponse or am I missing something?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi.
When I use the
transformErrorResponse
I can provide custom error type returned from this method.But it still doesn't infered when the mutation is called. So the result of calling mutation would still be
{ data: ResultType } | { error: FetchBaseQueryError | SerializedError }
while it should be something likeReturnType<typeof transformErrorResponse>
.Yes, I can write a guard for it, but this guard will allow a type other than my custom.
Also, I can cast the type (like,
result.error as MyCustomError
) but this not a good solution.So, my question here: why the type in not infered from
tranformErrorResponse
or am I missing something?Beta Was this translation helpful? Give feedback.
All reactions