Skip to content

Commit 0dbb7fd

Browse files
adimitsamavatijasonsaayman
authored
fix(types): change the type guard on isCancel (#5595)
* fix(types): change the type guard on isCancel … to `CanceledError<any>`. This makes more sense as it reflects what `isCancel` is actually doing. In fact, if I'm not mistaken, the `Cancel` type is no longer in the project. It got removed in 7f12366. It should probably also be removed from the types. * Parameterize `CanceledError` in `isCancel` Thanks to @samavati for the suggestion. Co-authored-by: Ehsan Samavati <[email protected]> --------- Co-authored-by: Ehsan Samavati <[email protected]> Co-authored-by: Jay <[email protected]>
1 parent 5a079ca commit 0dbb7fd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ export class AxiosError<T = unknown, D = any> extends Error {
443443
}
444444

445445
export class CanceledError<T> extends AxiosError<T> {
446+
readonly name: "CanceledError";
446447
}
447448

448449
export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
@@ -543,7 +544,7 @@ export function isAxiosError<T = any, D = any>(payload: any): payload is AxiosEr
543544

544545
export function spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
545546

546-
export function isCancel(value: any): value is Cancel;
547+
export function isCancel<T = any>(value: any): value is CanceledError<T>;
547548

548549
export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
549550

0 commit comments

Comments
 (0)