-
Notifications
You must be signed in to change notification settings - Fork 169
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
fix: enable name import #252
Closed
+2,120
−195
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { expectType } from 'tsd'; | ||
import axios, { AxiosError, AxiosRequestConfig } from 'axios'; | ||
import axiosRetry, { | ||
IAxiosRetryConfig, | ||
IAxiosRetryConfigExtended, | ||
IAxiosRetryReturn, | ||
exponentialDelay, | ||
isIdempotentRequestError, | ||
isNetworkError, | ||
isNetworkOrIdempotentRequestError, | ||
isRetryableError, | ||
isSafeRequestError | ||
} from './index.js'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I confirm that |
||
|
||
const axiosInstance = axios.create(); | ||
|
||
expectType<IAxiosRetryReturn>(axiosRetry(axios)); | ||
expectType<IAxiosRetryReturn>(axiosRetry(axiosInstance)); | ||
|
||
const axiosRetryConfig: IAxiosRetryConfig = { | ||
retries: 3, | ||
shouldResetTimeout: true, | ||
retryCondition: (error: AxiosError) => { | ||
return true; | ||
}, | ||
retryDelay: (retryCount: number, error: AxiosError) => { | ||
return 100; | ||
}, | ||
onRetry: (retryCount: number, error: AxiosError, requestConfig: AxiosRequestConfig) => { | ||
const axiosRetryConfig: IAxiosRetryConfigExtended | undefined = requestConfig['axios-retry']; | ||
console.log(retryCount, error, requestConfig, axiosRetryConfig); | ||
|
||
expectType<IAxiosRetryConfigExtended | undefined>(requestConfig['axios-retry']); | ||
expectType<number | undefined>(axiosRetryConfig?.retryCount); | ||
expectType<number | undefined>(axiosRetryConfig?.lastRequestTime); | ||
} | ||
}; | ||
expectType<IAxiosRetryReturn>(axiosRetry(axios, axiosRetryConfig)); | ||
|
||
expectType<IAxiosRetryReturn>(axiosRetry(axios, { retryCondition: axiosRetry.isNetworkError })); | ||
expectType<IAxiosRetryReturn>(axiosRetry(axios, { retryCondition: axiosRetry.isRetryableError })); | ||
expectType<IAxiosRetryReturn>(axiosRetry(axios, { retryCondition: axiosRetry.isSafeRequestError })); | ||
expectType<IAxiosRetryReturn>( | ||
axiosRetry(axios, { retryCondition: axiosRetry.isIdempotentRequestError }) | ||
); | ||
expectType<IAxiosRetryReturn>( | ||
axiosRetry(axios, { retryCondition: axiosRetry.isNetworkOrIdempotentRequestError }) | ||
); | ||
expectType<IAxiosRetryReturn>(axiosRetry(axios, { retryDelay: axiosRetry.exponentialDelay })); | ||
|
||
expectType<IAxiosRetryReturn>(axiosRetry(axios, { retryCondition: isNetworkError })); | ||
expectType<IAxiosRetryReturn>(axiosRetry(axios, { retryCondition: isRetryableError })); | ||
expectType<IAxiosRetryReturn>(axiosRetry(axios, { retryCondition: isSafeRequestError })); | ||
expectType<IAxiosRetryReturn>(axiosRetry(axios, { retryCondition: isIdempotentRequestError })); | ||
expectType<IAxiosRetryReturn>( | ||
axiosRetry(axios, { retryCondition: isNetworkOrIdempotentRequestError }) | ||
); | ||
expectType<IAxiosRetryReturn>(axiosRetry(axios, { retryDelay: exponentialDelay })); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those were not exported directly before. Those were exported through
AxiosRetry
which should be exported instead.I'd still want you to answer #250 (comment) more specifically because I'm not sure why the
export =
syntax doesn't work for you.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to conform to the specification in JavaScript. It is also possible to name import the
isNetworkError
function as follows.This time, it has been modified accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, you can export those since it's a "new feature" but you also have to export
AxiosRetry
since it was exported before and it was possible to doimport { AxiosRetry } from 'axios-retry'
while it's not possible with those changes.