-
Notifications
You must be signed in to change notification settings - Fork 23
Add types #661
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
Add types #661
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8a09b3c
Define interfaces for the plugin, state, and options
mbg 004621d
Type `errorRequest`
mbg b2f6eef
Type `retry`
mbg c4172d4
Avoid type assertion by only passing the plugin to the handlers
mbg 7d3b969
Add minimal typings for bottleneck
mbg f067f2f
Type `wrapRequest` and `requestWithGraphqlErrorHandling`
mbg 35d8fc3
Apply suggestions from code review
mbg 97b4a70
Format `types.ts`
mbg 8a1228c
Move `isRequestError` out of `types.ts`
mbg 02dccd8
Add type exports
wolfy1339 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,16 @@ | ||
| /** Minimal typings for "bottleneck/light.js" based on the usage in this library. */ | ||
| declare module "bottleneck/light.js" { | ||
| export type RetryableInfo = { readonly retryCount: number }; | ||
|
|
||
| export class Bottleneck { | ||
| constructor(options?: any); | ||
|
|
||
| on(name: "failed", fn: (error: any, info: RetryableInfo) => any): void; | ||
|
|
||
| schedule<A extends unknown[], R>( | ||
| task: (...args: A) => Promise<R>, | ||
| ...taskArgs: A | ||
| ): Promise<R>; | ||
| } | ||
| export default Bottleneck; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,26 @@ | ||
| import type { RequestError } from "@octokit/request-error"; | ||
|
|
||
| export interface RetryPlugin { | ||
| retry: { | ||
| retryRequest: ( | ||
| error: RequestError, | ||
| retries: number, | ||
| retryAfter: number, | ||
| ) => RequestError; | ||
| }; | ||
| } | ||
|
|
||
| export interface RetryState { | ||
| enabled: boolean; | ||
| retryAfterBaseValue: number; | ||
| doNotRetry: number[]; | ||
| retries: number; | ||
| } | ||
mbg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| export interface RetryOptions { | ||
| retry: RetryOptions; | ||
| } | ||
mbg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export function isRequestError(error: any): error is RequestError { | ||
| return error.request !== undefined; | ||
| } | ||
mbg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.