Skip to content

Commit

Permalink
Merge pull request #27 from danpan1/fix-types
Browse files Browse the repository at this point in the history
Fixed typings to Provide set Response Type
  • Loading branch information
int64ago authored Aug 24, 2019
2 parents 57ea039 + 8e60a0e commit a1cfde7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions types.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios';

export interface IParams {
export interface IParams<T> {
axios?: AxiosInstance;
url: string;
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'PATCH';
Expand All @@ -11,24 +11,24 @@ export interface IParams {
*/
filter?: () => boolean;
forceDispatchEffect?: () => boolean;
customHandler?: (error: null | Error, response: null | AxiosResponse) => void;
customHandler?: (error: null | Error, response: null | AxiosResponse<T>) => void;
}

export interface IResponseStatus {
response: null | AxiosResponse;
export interface IResponseStatus<T> {
response: null | AxiosResponse<T>;
error: null | Error;
loading: boolean;
}

export interface IReturns extends IResponseStatus {
export interface IReturns<T> extends IResponseStatus<T> {
/**
* @deprecated Alias of `reFetch`
*/
query: () => number;
reFetch: () => number;
}

declare const useAxios: (params: IParams) => IReturns;
declare const useAxios: <T = any>(params: IParams<T>) => IReturns<T>;
export default useAxios;

export declare const axios: AxiosInstance;

0 comments on commit a1cfde7

Please sign in to comment.