mirror of
https://github.com/axios/axios.git
synced 2026-04-15 03:26:10 +08: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:
parent
f8694341de
commit
8d1271b49f
22
index.d.cts
22
index.d.cts
@ -515,14 +515,32 @@ declare namespace axios {
|
||||
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> {
|
||||
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
||||
eject(id: number): void;
|
||||
clear(): void;
|
||||
handlers?: Array<AxiosInterceptorHandler<V>>;
|
||||
}
|
||||
|
||||
interface AxiosInstance extends Axios {
|
||||
|
||||
22
index.d.ts
vendored
22
index.d.ts
vendored
@ -494,14 +494,32 @@ export interface AxiosInterceptorOptions {
|
||||
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> {
|
||||
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
||||
eject(id: number): void;
|
||||
clear(): void;
|
||||
handlers?: Array<AxiosInterceptorHandler<V>>;
|
||||
}
|
||||
|
||||
export class Axios {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user