Skip to content
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

Fixing instance.defaults.headers type #4557

Merged
merged 5 commits into from May 9, 2022

Conversation

spalger
Copy link
Contributor

@spalger spalger commented Mar 29, 2022

When creating an Axios instance with Axios.create() the headers config (as described in the README) is merged into the root of instance.default.headers. These values are not accessible because the types for instance.defaults.headers do not include an index type to represent the arbitrary properties which are merged there.

This PR includes this index type in the instance.defaults.headers object and includes validation that this works in the test/typescript/axios.ts file. Without the change in index.d.ts this test shows the following error:

image

test/typescript/axios.ts Outdated Show resolved Hide resolved
@jasonsaayman jasonsaayman added follow-up Issue or pull request requires a follow. and removed follow-up Issue or pull request requires a follow. labels May 3, 2022
@jasonsaayman jasonsaayman removed the follow-up Issue or pull request requires a follow. label May 9, 2022
@jasonsaayman jasonsaayman merged commit 9f6ba5e into axios:master May 9, 2022
3 checks passed
@jasonsaayman
Copy link
Member

jasonsaayman commented May 9, 2022

Thanks for the contribution 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants