Skip to content

Commit

Permalink
Fixing isAxiosError typings to take generics
Browse files Browse the repository at this point in the history
  • Loading branch information
latipun7 committed Oct 1, 2021
1 parent 76f09af commit 12fff93
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions index.d.ts
Expand Up @@ -16,7 +16,7 @@ export interface AxiosProxyConfig {
port: number;
auth?: {
username: string;
password:string;
password: string;
};
protocol?: string;
}
Expand All @@ -31,17 +31,17 @@ export type Method =
| 'patch' | 'PATCH'
| 'purge' | 'PURGE'
| 'link' | 'LINK'
| 'unlink' | 'UNLINK'
| 'unlink' | 'UNLINK';

export type ResponseType =
| 'arraybuffer'
| 'blob'
| 'document'
| 'json'
| 'text'
| 'stream'
| 'stream';

export interface TransitionalOptions{
export interface TransitionalOptions {
silentJSONParsing: boolean;
forcedJSONParsing: boolean;
clarifyTimeoutError: boolean;
Expand Down Expand Up @@ -77,11 +77,11 @@ export interface AxiosRequestConfig<T = any> {
proxy?: AxiosProxyConfig | false;
cancelToken?: CancelToken;
decompress?: boolean;
transitional?: TransitionalOptions
transitional?: TransitionalOptions;
signal?: AbortSignal;
}

export interface AxiosResponse<T = never> {
export interface AxiosResponse<T = never> {
data: T;
status: number;
statusText: string;
Expand All @@ -99,8 +99,7 @@ export interface AxiosError<T = never> extends Error {
toJSON: () => object;
}

export interface AxiosPromise<T = never> extends Promise<AxiosResponse<T>> {
}
export interface AxiosPromise<T = never> extends Promise<AxiosResponse<T>> {}

export interface CancelStatic {
new (message?: string): Cancel;
Expand Down Expand Up @@ -131,7 +130,10 @@ export interface CancelTokenSource {
}

export interface AxiosInterceptorManager<V> {
use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any): number;
use<T = V>(
onFulfilled?: (value: V) => T | Promise<T>,
onRejected?: (error: any) => any
): number;
eject(id: number): void;
}

Expand Down Expand Up @@ -167,7 +169,7 @@ export interface AxiosStatic extends AxiosInstance {
isCancel(value: any): boolean;
all<T>(values: (T | Promise<T>)[]): Promise<T[]>;
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
isAxiosError(payload: any): payload is AxiosError;
isAxiosError<T = any>(payload: any): payload is AxiosError<T>;
}

declare const axios: AxiosStatic;
Expand Down

0 comments on commit 12fff93

Please sign in to comment.