softonic / axios-retry

Axios plugin that intercepts failed requests and retries them whenever possible
Other
1.9k stars 167 forks source link

Incomplete type for retryCondition #136

Closed karlismelderis closed 4 years ago

karlismelderis commented 4 years ago

I think we're missing bit in retryCondition type

error argument is not pure axios.AxiosError axios-retry actually is adding one more property to it:

config: {
'axios-retry': { retryCount: 0, lastRequestTime: 1111 },
}

can you please extend the type?

I tried to add this bit to your index.d.ts and it solved the case for me:

declare module 'axios' {
  interface AxiosRequestConfig {
    'axios-retry': {
      retryCount: number
      lastRequestTime: number
    }
  }
}
Jokero commented 4 years ago

@karlismelderis Why do you need retryCount and lastRequestTime fields there? I guess this should be enough:

declare module 'axios' {
    export interface AxiosRequestConfig {
        'axios-retry'?: IAxiosRetryConfig;
    }
}

Where IAxiosRetryConfig is this https://github.com/softonic/axios-retry/blob/v3.1.8/index.d.ts#L25-L53. Take a look at PR https://github.com/softonic/axios-retry/pull/149