mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
fix(types): add handlers to AxiosInterceptorManager interface (#5551)
* fix(types): add handlers to AxiosInterceptorManager interface * fix: runwhen should be optional Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: make handlers optional * chore: optional handlers --------- Co-authored-by: Tibor Pilz <tibor.pilz@iu.org> Co-authored-by: Jay <jasonsaayman@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
+20
-2
@@ -515,14 +515,32 @@ declare namespace axios {
|
|||||||
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type AxiosRequestInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions) => number;
|
type AxiosInterceptorFulfilled<T> = (value: T) => T | Promise<T>;
|
||||||
|
type AxiosInterceptorRejected = (error: any) => any;
|
||||||
|
|
||||||
type AxiosResponseInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null) => number;
|
type AxiosRequestInterceptorUse<T> = (
|
||||||
|
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
|
||||||
|
onRejected?: AxiosInterceptorRejected | null,
|
||||||
|
options?: AxiosInterceptorOptions
|
||||||
|
) => number;
|
||||||
|
|
||||||
|
type AxiosResponseInterceptorUse<T> = (
|
||||||
|
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
|
||||||
|
onRejected?: AxiosInterceptorRejected | null
|
||||||
|
) => number;
|
||||||
|
|
||||||
|
interface AxiosInterceptorHandler<T> {
|
||||||
|
fulfilled: AxiosInterceptorFulfilled<T>;
|
||||||
|
rejected?: AxiosInterceptorRejected;
|
||||||
|
synchronous: boolean;
|
||||||
|
runWhen?: (config: AxiosRequestConfig) => boolean;
|
||||||
|
}
|
||||||
|
|
||||||
interface AxiosInterceptorManager<V> {
|
interface AxiosInterceptorManager<V> {
|
||||||
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
||||||
eject(id: number): void;
|
eject(id: number): void;
|
||||||
clear(): void;
|
clear(): void;
|
||||||
|
handlers?: Array<AxiosInterceptorHandler<V>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AxiosInstance extends Axios {
|
interface AxiosInstance extends Axios {
|
||||||
|
|||||||
Vendored
+20
-2
@@ -494,14 +494,32 @@ export interface AxiosInterceptorOptions {
|
|||||||
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type AxiosRequestInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions) => number;
|
type AxiosInterceptorFulfilled<T> = (value: T) => T | Promise<T>;
|
||||||
|
type AxiosInterceptorRejected = (error: any) => any;
|
||||||
|
|
||||||
type AxiosResponseInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null) => number;
|
type AxiosRequestInterceptorUse<T> = (
|
||||||
|
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
|
||||||
|
onRejected?: AxiosInterceptorRejected | null,
|
||||||
|
options?: AxiosInterceptorOptions
|
||||||
|
) => number;
|
||||||
|
|
||||||
|
type AxiosResponseInterceptorUse<T> = (
|
||||||
|
onFulfilled?: AxiosInterceptorFulfilled<T> | null,
|
||||||
|
onRejected?: AxiosInterceptorRejected | null
|
||||||
|
) => number;
|
||||||
|
|
||||||
|
interface AxiosInterceptorHandler<T> {
|
||||||
|
fulfilled: AxiosInterceptorFulfilled<T>;
|
||||||
|
rejected?: AxiosInterceptorRejected;
|
||||||
|
synchronous: boolean;
|
||||||
|
runWhen: (config: AxiosRequestConfig) => boolean | null;
|
||||||
|
}
|
||||||
|
|
||||||
export interface AxiosInterceptorManager<V> {
|
export interface AxiosInterceptorManager<V> {
|
||||||
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
||||||
eject(id: number): void;
|
eject(id: number): void;
|
||||||
clear(): void;
|
clear(): void;
|
||||||
|
handlers?: Array<AxiosInterceptorHandler<V>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Axios {
|
export class Axios {
|
||||||
|
|||||||
Reference in New Issue
Block a user