Skip to content

Commit 3a8b87d

Browse files
authored
Fixing an issue that type 'null' and 'undefined' is not assignable to validateStatus when typescript strict option is enabled (#3200)
1 parent 9a78465 commit 3a8b87d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface AxiosRequestConfig {
6262
onUploadProgress?: (progressEvent: any) => void;
6363
onDownloadProgress?: (progressEvent: any) => void;
6464
maxContentLength?: number;
65-
validateStatus?: ((status: number) => boolean | null);
65+
validateStatus?: ((status: number) => boolean) | null;
6666
maxBodyLength?: number;
6767
maxRedirects?: number;
6868
socketPath?: string | null;

test/typescript/axios.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ const config: AxiosRequestConfig = {
4444
cancelToken: new axios.CancelToken((cancel: Canceler) => {})
4545
};
4646

47+
const nullValidateStatusConfig: AxiosRequestConfig = {
48+
validateStatus: null
49+
};
50+
51+
const undefinedValidateStatusConfig: AxiosRequestConfig = {
52+
validateStatus: undefined
53+
};
54+
4755
const handleResponse = (response: AxiosResponse) => {
4856
console.log(response.data);
4957
console.log(response.status);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy