diff --git a/__fixtures__/error-axios-404.ts b/__fixtures__/error-axios-404.ts index fea69ff..7c94a95 100644 --- a/__fixtures__/error-axios-404.ts +++ b/__fixtures__/error-axios-404.ts @@ -20,6 +20,6 @@ export default createError( 'Request failed with status code 404', RESPONSE.config, undefined, - {} as unknown as ClientRequest, + {} as ClientRequest | XMLHttpRequest, RESPONSE ) as AxiosErrorType diff --git a/__fixtures__/error-axios-no-res.ts b/__fixtures__/error-axios-no-res.ts index 96e5447..7e0f805 100644 --- a/__fixtures__/error-axios-no-res.ts +++ b/__fixtures__/error-axios-no-res.ts @@ -13,5 +13,5 @@ export default createError( 'Request failed with status code 500', config, 'ECONNABORTED', - {} as unknown as ClientRequest + {} as ClientRequest | XMLHttpRequest ) diff --git a/src/interfaces/axios-error.ts b/src/interfaces/axios-error.ts index 2268b4b..1768957 100644 --- a/src/interfaces/axios-error.ts +++ b/src/interfaces/axios-error.ts @@ -21,7 +21,7 @@ interface AxiosError extends Error { readonly code?: string readonly config: AxiosRequestConfig readonly isAxiosError: boolean - readonly request?: ClientRequest + readonly request?: ClientRequest | XMLHttpRequest readonly response?: AxiosResponse toJSON(): AxiosErrorJSON } diff --git a/tsconfig.json b/tsconfig.json index 1430f66..fab1a1e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,7 @@ "experimentalDecorators": true, "forceConsistentCasingInFileNames": true, "isolatedModules": false, - "lib": ["es2021"], + "lib": ["dom", "es2021"], "module": "esnext", "moduleResolution": "node", "newLine": "lf", diff --git a/typings/axios/lib/core/createError.d.ts b/typings/axios/lib/core/createError.d.ts index f5ba377..5696065 100644 --- a/typings/axios/lib/core/createError.d.ts +++ b/typings/axios/lib/core/createError.d.ts @@ -7,7 +7,7 @@ declare module 'axios/lib/core/createError' { message: string, config: AxiosRequestConfig, code?: string, - request?: ClientRequest, + request?: ClientRequest | XMLHttpRequest, response?: AxiosResponse ): AxiosError }