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 465a617
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions index.d.ts
Original file line number Diff line number Diff line change
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 @@ -167,7 +166,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 465a617

Please sign in to comment.