Skip to content
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

Cancel type definition is wrong #6041

Open
miaSlady opened this issue Oct 29, 2023 · 2 comments · May be fixed by #6042
Open

Cancel type definition is wrong #6041

miaSlady opened this issue Oct 29, 2023 · 2 comments · May be fixed by #6042

Comments

@miaSlady
Copy link

Describe the bug

Source Code

isCancel(value: any): value is Cancel;

interface Cancel {
   message: string | undefined;
}

To Reproduce

Example

 import axios, {isCancel, AxiosError} from 'axios';

 axios.get('/user?ID=12345')
.then(function (response) {
  // handle success
  console.log(response);
})
.catch(function (error: AxiosError) {
    if (isCancel(error)) {

   } else {
     // error type is never
  }
})

Code snippet

No response

Expected behavior

No response

Axios Version

1.6.0

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

No response

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

@miaSlady miaSlady linked a pull request Oct 29, 2023 that will close this issue
@Youngemmy5956
Copy link

Youngemmy5956 commented Nov 1, 2023

interface Cancel {
message: string | undefined;
}

// Update the type definition to be a function
const isCancel = (value: any): value is Cancel => {
return value && value.message !== undefined;
};

Have u tried this???

@pkerschbaum
Copy link

duplicate of #5153

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 a pull request may close this issue.

3 participants