Conversation
There was a problem hiding this comment.
It would probably make sense to introduce a specifc AxiosHeaders type:
type AxiosHeaders = Record<Exclude<"set-cookie", string>, string> & {
"set-cookie"?: string[]
}Note that it is also used in the AxiosTransformer and AxiosRequestConfiginterfaces:
Lines 1 to 3 in 6c00232
Lines 50 to 56 in 6c00232
|
You might want to wait until #4140 is merged, because it adds a new |
|
👍 for differentiating The common ground would be to keep |
Haha sorry – I was referring to that PR assigning things to type aliases, I should have clarified that! Was sharing that the two PRs could build from one another 😄 |
|
Actually, #4117 was the first PR to suggest adding a |
I like this idea! But it doesn’t work. After some fiddling I came up with: type AxiosHeaders = Record<string, string> & {
"set-cookie"?: string[]
}Also we may want to differentiate between request and response headers, as type AxiosRequestHeaders = Record<string, string>;
type AxiosResponseHeaders = Record<string, string> & {
"set-cookie"?: string[]
}; |
I have a question about this code, |
@EyebrowsWhite Not sure why it doesn't work when declaring the header object directly, but the following works (see playground): type AxiosHeaders = Record<string, string> & {
"set-cookie"?: string[]
}
declare let headers: AxiosHeaders;
headers = {}
headers['Content-Type'] = 'text/plain'
headers['set-cookie'] = ['abc', 'def'] |
* fix response headers types some keys like 'set-cookie' are arrays https://github.com/axios/axios/blob/master/lib/helpers/parseHeaders.js#L45 * split header types
some keys like 'set-cookie' are arrays https://github.com/axios/axios/blob/master/lib/helpers/parseHeaders.js#L45