New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type of AxiosError gets narrowed down after isCancel
check
#5153
Comments
We ran into this, too. Since #4293, isCancel(value: any): value is Cancel; That's all well and good in the positive case, but in the negative case, this type guard asserts that export interface Cancel {
message: string | undefined;
} So this implies that whatever The actual runtime of I think the type guard for Curiously, there's a isCancel(value: any): value is CanceledError
Unfortunately, this doesn't seem to fix the problem. The type guard seems to still refute PS: Ah, I found out what |
OK, I found out why my fix didn't work. I've opened up a bug in TS, and I know of a workaround. I'll post a PR. Edit: it's not a bug in TS. TS considers this working as intended. |
workaround in project
|
Describe the bug
After a
isCancel
check the type of the argument passed gets narrowed down, losing theAxiosError
type.The type is not narrowed down in version 0.27.2.
To Reproduce
https://typescript-l4zgey.stackblitz.io/
Code snippet
Expected behavior
Type
AxiosError
should not be excluded after aisCancel
check.Axios Version
1.1.3
Adapter Version
No response
Browser
No response
Browser Version
No response
Node.js Version
16.16.0
OS
OSX 12.6.0
Additional Library Versions
Additional context/Screenshots
No response
The text was updated successfully, but these errors were encountered: