Skip to content

Fixed typings to Provide set Response Type #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;