Types prevent adding new values to headers
See original GitHub issueDescribe the bug
Types prevent adding new values to headers
To Reproduce
function getRequestConfig(options: AxiosRequestConfig): AxiosRequestConfig {
return {
...options,
headers: {
...options.headers,
Authorization: `Bearer ...`,
},
};
}
TS2322: Type '{ Authorization: string; get?: AxiosHeaders | undefined; delete?: AxiosHeaders | undefined; head?: AxiosHeaders | undefined; options?: AxiosHeaders | undefined; ... 6 more ...; common?: AxiosHeaders | undefined; }' is not assignable to type 'Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>'.
Property 'get' is incompatible with index signature.
Type 'AxiosHeaders' is not assignable to type 'AxiosHeaderValue | undefined'.
Expected behavior
Everything is working
Environment
- Axios Version 1.0.0
Issue Analytics
- State:
- Created a year ago
- Reactions:9
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Content-Type - HTTP - MDN Web Docs - Mozilla
In requests, (such as POST or PUT ), the client tells the server what type of data is actually sent. Header type, Representation...
Read more >Promote or demote rows and column headers (Power Query)
To open a query, locate one previously loaded from the Power Query Editor, select a cell in the data, and then select Query...
Read more >Power Query: Avoiding naming column headers to avoid breaks
Here are the custom M functions I use: Create a list of column names : Table.ColumnNames(Source) Convert values into their type (e.g. date, ......
Read more >Prevent pandas read_csv treating first row as header of ...
You want header=None the False gets type promoted to int into 0 see the docs emphasis mine: header : int or list of...
Read more >HTTP security headers: An easy way to harden your web ...
The recommended way to prevent website certificate spoofing is to use the Expect-CT header to indicate that only new certificates added to ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Type ‘Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders> | undefined’ is not assignable to type ‘AxiosRequestHeaders | undefined’. Type ‘Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>’ is not assignable to type ‘AxiosRequestHeaders’. Type ‘Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>’ is missing the following properties from type ‘AxiosHeaders’: set, has, clear, normalize, and 17 more.
Axios version :1.2.0
is there a fix to this
I got this :
Error: Type '{ Authorization: string; }' is not assignable to type 'Partial<HeadersDefaults> | Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders> | undefined'.Axios : version 1.1.3
const client = axios.create({ baseURL: API_URL, timeout: 1000, headers: {Authorization: ``Bearer ${OAUTH_TOKEN}``}, });what’s wrong ?