Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export interface AxiosRequestConfig {
onUploadProgress?: (progressEvent: ProgressEvent) => void;
onDownloadProgress?: (progressEvent: ProgressEvent) => void;
maxContentLength?: number;
validateStatus?: ((status: number) => boolean | null);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

LGTM! Type signature correctly allows null return value.

The change properly expands the return type to boolean | null, which fixes the type error when users return null from their validateStatus implementation. The parentheses correctly scope the union type to the return value.Important: The type signature should be ((status: number) => boolean) | null rather than ((status: number) => boolean | null). The current implementation parses as a function that returns boolean | null, but the intended fix should allow the entire property to be set to null.

According to Axios documentation, validateStatus can be assigned a function, undefined, or null to the property itself. When set to null or undefined, all status codes resolve the promise.

🐛 Proposed fix for the type signature
-  validateStatus?: ((status: number) => boolean | null);
+  validateStatus?: ((status: number) => boolean) | null;

This was also noted in the original Axios PR discussion where the same mistake was made and later corrected in PR #3200.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
validateStatus?: ((status: number) => boolean | null);
validateStatus?: ((status: number) => boolean) | null;
🤖 Prompt for AI Agents
In `@index.d.ts` at line 65, The type for validateStatus is wrong: it currently
defines a function that returns boolean|null but should allow the entire
property to be null; change the signature for validateStatus so the union
applies to the property (i.e., ((status: number) => boolean) | null) instead of
((status: number) => boolean | null), updating the declaration named
validateStatus in index.d.ts so callers can assign null to the property itself.

maxBodyLength?: number;
validateStatus?: (status: number) => boolean;
maxRedirects?: number;
socketPath?: string | null;
httpAgent?: any;
Expand Down