Define string key for AxiosXHRConfigBase.headers (#11976)

When setting headers, tsc complains that "Index signature of object type implicitly has an 'any' type."
E.g. ajaxSettings.headers["Authorization"] = "secret";
This commit is contained in:
Ryan Price
2016-10-16 10:26:54 -04:00
committed by Masahiro Wakame
parent 34e2854b9e
commit e6215d4444
2 changed files with 5 additions and 1 deletions

View File

@@ -69,6 +69,10 @@ axios.post("http://example.com/", {
]
});
var config: Axios.AxiosXHRConfigBase<any> = {headers: {}};
config.headers['X-Custom-Header'] = 'baz';
axios.post("http://example.com/", config);
var getRepoIssue = axios.get<Issue>("https://api.github.com/repos/mzabriskie/axios/issues/1");
var axiosInstance = axios.create({

2
axios/axios.d.ts vendored
View File

@@ -39,7 +39,7 @@ declare namespace Axios {
/**
* custom headers to be sent
*/
headers?: Object;
headers?: {[key: string]: any};
/**
* URL parameters to be sent with the request