From 9f6ba5ee4326d33d2b84aef591582a26cc892d4d Mon Sep 17 00:00:00 2001 From: Spencer Date: Mon, 9 May 2022 12:12:53 -0500 Subject: [PATCH] Fixing instance.defaults.headers type (#4557) * Fixing instance.defaults.headers type * remove console.log() Co-authored-by: Jay --- index.d.ts | 6 ++++++ test/typescript/axios.ts | 2 ++ 2 files changed, 8 insertions(+) diff --git a/index.d.ts b/index.d.ts index 94b076c..6a83f60 100644 --- a/index.d.ts +++ b/index.d.ts @@ -241,6 +241,12 @@ export class Axios { export interface AxiosInstance extends Axios { (config: AxiosRequestConfig): AxiosPromise; (url: string, config?: AxiosRequestConfig): AxiosPromise; + + defaults: Omit & { + headers: HeadersDefaults & { + [key: string]: string | number | boolean | undefined + } + }; } export interface GenericFormData { diff --git a/test/typescript/axios.ts b/test/typescript/axios.ts index 7c304de..66b6b3d 100644 --- a/test/typescript/axios.ts +++ b/test/typescript/axios.ts @@ -251,6 +251,8 @@ instance1.post('/user', { foo: 'bar' }, { headers: { 'X-FOO': 'bar' } }) // Defaults +axios.defaults.headers['X-FOO']; + axios.defaults.baseURL = 'https://api.example.com/'; axios.defaults.headers.common['Authorization'] = 'token'; axios.defaults.headers.post['X-FOO'] = 'bar';