New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updated interceptor use type definition to remove interceptor options parameter from use method for response interceptors #5237
base: v1.x
Are you sure you want to change the base?
Conversation
… parameter from use method for response interceptors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution and it looks good, however can you please pull the changes to the index.d.cts too?
@jasonsaayman I can't seem to understand what you mean. There isn't any |
@amitsainii the file is over here we use two sets of types one for CommonJS and one for ESM 😄 |
Thanks, @jasonsaayman I added the type definitions to |
@DigitalBrainJS Is this good to go in our next release? In case there are any blockers please let me know, thanks. |
@DigitalBrainJS Can we unblock this, please? I don't think any further changes are needed here. Please let me know if you need more info related to the changes |
@jasonsaayman @DigitalBrainJS This has approval from both of you. Please let me know if there's still something that's stopping this from getting merged. |
With Axios
1.x
we introduced an optional third argument for our interceptoruse
function. When I looked at the source code, I realized this third param of typeAxiosInterceptorOptions
is only used for request interceptor.The issue I'm reporting is related to the typescript definition for the use method. Currently, when it comes to this third parameter, type definitions don't distinguish between request and response interceptors. Because of this currently, this third argument can be used on the response interceptor as well without typescript yelling at you. This is misguiding for our consumers as they may end up using
runWhen
on response interceptors which won't do anything.This PR fixes this problem by using conditional type for
use
method whereinAxiosResponseInterceptorUse
does not include an options parameter in the type definition.Fixes: #5074