-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Incomplete typings for AxiosRequestHeaders #4335
Copy link
Copy link
Closed
Description
Describe the bug
AxiosRequestHeaders is currently only a Record for primitives Record<string, string | number | boolean> and, according to typing cannot have object as values. In reality, headers under keys can objects with other keys. A good example is from README:
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
To Reproduce
F.e. if we were to delete a header entry in transformRequest we would get a typescript error Property 'Authorization' does not exist on type 'string'.
return axios({
method : 'get',
transformRequest: (data, headers) => {
delete headers?.common?.Authorization;
}
})Expected behavior
To be able to access / delete headers under the whole list of keys common, post, etc
Environment
- Axios Version 0.24.0
- Adapter HTTP
Additional context/Screenshots
This is a typescript bug
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels