Skip to content

Commit

Permalink
fix(interfaces): add XMLHttpRequest to AxiosError#request definition
Browse files Browse the repository at this point in the history
  • Loading branch information
unicornware committed Aug 29, 2022
1 parent 956dd03 commit edaa93f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion __fixtures__/error-axios-404.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion __fixtures__/error-axios-no-res.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export default createError(
'Request failed with status code 500',
config,
'ECONNABORTED',
{} as unknown as ClientRequest
{} as ClientRequest | XMLHttpRequest
)
2 changes: 1 addition & 1 deletion src/interfaces/axios-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface AxiosError<Payload = any, Data = any> extends Error {
readonly code?: string
readonly config: AxiosRequestConfig<Data>
readonly isAxiosError: boolean
readonly request?: ClientRequest
readonly request?: ClientRequest | XMLHttpRequest
readonly response?: AxiosResponse<Payload, Data>
toJSON(): AxiosErrorJSON<Data>
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": false,
"lib": ["es2021"],
"lib": ["dom", "es2021"],
"module": "esnext",
"moduleResolution": "node",
"newLine": "lf",
Expand Down
2 changes: 1 addition & 1 deletion typings/axios/lib/core/createError.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ declare module 'axios/lib/core/createError' {
message: string,
config: AxiosRequestConfig<Data>,
code?: string,
request?: ClientRequest,
request?: ClientRequest | XMLHttpRequest,
response?: AxiosResponse<Payload, Data>
): AxiosError<Payload, Data>
}

0 comments on commit edaa93f

Please sign in to comment.