Skip to content

Fixing an issue that type 'null' is not assignable to validateStatus …#8

Open
MitchLewis930 wants to merge 1 commit intopr_028_beforefrom
pr_028_after
Open

Fixing an issue that type 'null' is not assignable to validateStatus …#8
MitchLewis930 wants to merge 1 commit intopr_028_beforefrom
pr_028_after

Conversation

@MitchLewis930
Copy link

@MitchLewis930 MitchLewis930 commented Jan 29, 2026

PR_028

Summary by CodeRabbit

Release Notes

  • Refactor
    • Updated request validation configuration type system to support extended return values, enabling more flexible validation logic in API request handling.

✏️ Tip: You can customize this high-level summary in your review settings.

…xios#2773)

Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

The validateStatus method signature in the AxiosRequestConfig TypeScript type definition has been updated to accept null as a valid return value alongside boolean, expanding the validation contract without removing the property.

Changes

Cohort / File(s) Summary
Type Definition Update
index.d.ts
Updated validateStatus method return type from (status: number) => boolean to (status: number) => boolean | null, allowing null as a valid return value in the validation function.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A status check, now with a twist so fine,
Boolean or null—the types align,
One tiny change, so small and neat,
Makes validation feel complete!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating the validateStatus type signature to allow null returns, which directly addresses the issue of null not being assignable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@MitchLewis930
Copy link
Author

@CodeRabbit full review

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@index.d.ts`:
- 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.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 029c36e and b03f161.

📒 Files selected for processing (1)
  • index.d.ts

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants