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
axios 1.2.3 causes an AxiosHeader error #5476
Comments
in 1.2.2 ,it work |
herader is not required to use it |
I think this was a type-breaking change introduced in #5420 You now need to replace usage of |
|
follow up issue of #5416 |
such as
This means that all types that use AxiosRequestConfig need to be replaced All with RawAxiosRequestConfig ? |
@laterdayi yep, because the headers property is mandatory in the But I'm not sure if the behaviour changes again in an upcoming release :person_shrugging: |
@tada5hi The current solution is to change everything you use with AxiosRequestConfig to RawAxiosRequestConfig, right? |
@laterdayi Taking into account the current version, yes. This should also avoid the following generic bug: #5478 |
@tada5hi Expect the next release to fix this |
Another problem here is that you cannot create, with valid typescript, a instance of // Type '{}' is missing the following properties from type
// 'AxiosHeaders': set, get, has, delete, and 19 more.
const headers: AxiosRequestHeaders = {};
// Type 'AxiosHeaders' is not assignable to type
// 'Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>'
const headers: AxiosRequestHeaders = new AxiosHeaders(); |
|
The PR #5420 ontroduced a breaking API change in a patch versin release 1.2.3. This also broke our pipeline. As mentioned replacing |
Can confirm this works for us! 🙌 |
I wonder if it can be fixed in the next version, or has Axios decided to change from AxiosRequestConfig to RawAxiosRequestConfig? |
That's another thing we should think about. Why make everyone change from |
@arthurfiorette This was the second solution considered, however, it doesn't really fit in with the current naming convention where the |
@DigitalBrainJS May I ask when the confirmed scheme will be available? Shall we change it to RawAxiosRequestConfig or fix this problem in the next version |
regardless of what the best way to address the internal/external config going forward, surely there's realization that the harm done by 1.2.3 far outweighs the benefit and 1.2.3 should be "pulled". Patch releases simply should not break builds. |
Switching to RawAxiosRequestConfig doesn't appear to work for the const options: RawAxiosRequestConfig = {
method: 'GET',
url: '/someurl',
};
const { data } = await apiClient.request<SomeClientSpecificResponseType>(options); Causes error:
|
@jameyg42 Definitely should, however, it is not always possible to make a fix for one thing without any impact on another. It seems that no matter what solution we choose here, the consequences cannot be completely avoided. The only question is where they will appear and how significantly they will affect. |
What about the prefix To me, |
So it seems there are three options:
Any suggestions are welcome. |
Can we use 3 until next big release? |
I don't think 1 is quite right - see #5476 (comment) |
@arthurfiorette If we are still going to rename the interface in the next major version, then the 2nd option could be preferable since users who have already changed the interface's name will not be forced to rename it back. I don't think they'll be thrilled about it :) Of course, it depends on whether users use the updated AxiosConfig interface somewhere as an internal config or not. We need to think carefully about this step. |
I believe option 2 is the best approach at this point. We'll keep the fix introduced by #5420 to solve issue #5415 while leaving the interface name as before. Still a (relatively) small breaking change because of the required prop, but users won't have to change |
This is another big piece to consider, though 🤔 |
Note: we do not upgrade `axios` here, because the 1.2.2 -> 1.2.3 inexplicably breaks our `primer-api.ts` bindings. See: axios/axios#5476 I'm shocked that they made this change in a minor point release!
Note: we do not upgrade `axios` here, because the 1.2.2 -> 1.2.3 inexplicably breaks our `primer-api.ts` bindings. See: axios/axios#5476 I'm shocked that they made this change in a minor point release!
|
Describe the bug
axios 1.2.3 causes an AxiosHeader error
The type {Token: string; Refresh: string; } "to type" AxiosRequestHeaders ".
Type "{Token: string; Refresh: string; } "Missing the following properties for type" AxiosHeaders ": set, get, has, delete and 19 others
Type "{params: {LayoutId: (string | number | null) []; check: string; }; } "cannot be assigned to an argument of type" AxiosRequestConfig ".
Type {params: {" LayoutId: (string | number | null) []; check: string; }; The attribute "headers" is missing from "}", but is required for type "AxiosRequestConfig"
To Reproduce
No response
Code snippet
No response
Expected behavior
No response
Axios Version
No response
Adapter Version
No response
Browser
No response
Browser Version
No response
Node.js Version
No response
OS
No response
Additional Library Versions
No response
Additional context/Screenshots
No response
The text was updated successfully, but these errors were encountered: