Skip to content

Commit

Permalink
Merge pull request #241 from yutak23/fix-typings
Browse files Browse the repository at this point in the history
fix: ESM default import `This expression is not callable`
  • Loading branch information
mindhells authored Aug 28, 2023
2 parents eab03a3 + ff1e07e commit fa31aea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 34 deletions.
60 changes: 27 additions & 33 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,62 @@
import * as axios from 'axios'
import * as axios from 'axios';

interface IAxiosRetry {
(
axios: axios.AxiosStatic | axios.AxiosInstance,
axiosRetryConfig?: IAxiosRetry.IAxiosRetryConfig
): IAxiosRetry.IAxiosRetryReturn;
export = IAxiosRetry;
export as namespace axiosRetry;
declare const IAxiosRetry: IAxiosRetry.AxiosRetry;

isNetworkError(error: Error): boolean;
isRetryableError(error: Error): boolean;
isSafeRequestError(error: Error): boolean;
isIdempotentRequestError(error: Error): boolean;
isNetworkOrIdempotentRequestError(error: Error): boolean;
exponentialDelay(retryNumber?: number, error?: Error, delayFactor?: number): number;
}
declare namespace IAxiosRetry {
export interface AxiosRetry {
(
axios: axios.AxiosStatic | axios.AxiosInstance,
axiosRetryConfig?: IAxiosRetryConfig
): IAxiosRetryReturn;

export function isNetworkError(error: Error): boolean;
export function isRetryableError(error: Error): boolean;
export function isSafeRequestError(error: Error): boolean;
export function isIdempotentRequestError(error: Error): boolean;
export function isNetworkOrIdempotentRequestError(error: Error): boolean;
export function exponentialDelay(retryNumber?: number, error?: Error, delayFactor?: number): number;
isNetworkError(error: Error): boolean;
isRetryableError(error: Error): boolean;
isSafeRequestError(error: Error): boolean;
isIdempotentRequestError(error: Error): boolean;
isNetworkOrIdempotentRequestError(error: Error): boolean;
exponentialDelay(retryNumber?: number, error?: Error, delayFactor?: number): number;
}

declare namespace IAxiosRetry {
export interface IAxiosRetryConfig {
/**
* The number of times to retry before failing
* default: 3
*
* @type {number}
*/
retries?: number,
retries?: number;
/**
* Defines if the timeout should be reset between retries
* default: false
*
* @type {boolean}
*/
shouldResetTimeout?: boolean,
shouldResetTimeout?: boolean;
/**
* A callback to further control if a request should be retried.
* default: it retries if it is a network error or a 5xx error on an idempotent request (GET, HEAD, OPTIONS, PUT or DELETE).
*
* @type {Function}
*/
retryCondition?: (error: axios.AxiosError) => boolean | Promise<boolean>,
retryCondition?: (error: axios.AxiosError) => boolean | Promise<boolean>;
/**
* A callback to further control the delay between retry requests. By default there is no delay.
*
* @type {Function}
*/
retryDelay?: (retryCount: number, error: axios.AxiosError) => number
retryDelay?: (retryCount: number, error: axios.AxiosError) => number;
/**
* A callback to get notified when a retry occurs, the number of times it has occurre, and the error
*
* @type {Function}
*/
onRetry?: (retryCount: number, error: axios.AxiosError, requestConfig: axios.AxiosRequestConfig) => void
onRetry?: (
retryCount: number,
error: axios.AxiosError,
requestConfig: axios.AxiosRequestConfig
) => void;
}

export interface IAxiosRetryReturn {
Expand All @@ -74,15 +75,8 @@ declare namespace IAxiosRetry {
}
}

declare const axiosRetry: IAxiosRetry;

export type IAxiosRetryConfig = IAxiosRetry.IAxiosRetryConfig;
export type IAxiosRetryReturn = IAxiosRetry.IAxiosRetryReturn;

export default axiosRetry;

declare module 'axios' {
export interface AxiosRequestConfig {
'axios-retry'?: IAxiosRetryConfig;
'axios-retry'?: IAxiosRetry.IAxiosRetryConfig;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"bugs": {
"url": "https://github.com/softonic/axios-retry/issues"
},
"typings": "./index.d.ts",
"types": "./index.d.ts",
"main": "index.js",
"module": "lib/esm/index.js",
"exports": {
Expand Down

0 comments on commit fa31aea

Please sign in to comment.