Skip to content

Commit 24d20a6

Browse files
authored
FEATURE-RELEASE: Add Typescript declarations (#42)
This makes it possible to use `@adobe/node-fetch-retry` in Typescript projects. It is _also_ used by recent ESLint versions for extra type-checking goodness, where e.g. missing returns or incorrect return types are made immediately obvious already while editing code in an IDE. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 531f3e8 commit 24d20a6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

index.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {RequestInfo, RequestInit, Response} from 'node-fetch'
2+
3+
export interface RequestInitWithRetry extends RequestInit {
4+
retryOptions?: {
5+
retryMaxDuration?: number
6+
retryInitialDelay?: number
7+
retryBackoff?: number
8+
retryOnHttpError?: (error: Error) => boolean
9+
retryOnHttpResponse?: (response: Response) => boolean
10+
socketTimeout?: number
11+
forceSocketTimeout?: boolean
12+
}
13+
}
14+
15+
declare function fetch(
16+
url: RequestInfo,
17+
init?: RequestInitWithRetry
18+
): Promise<Response>
19+
20+
export default fetch

0 commit comments

Comments
 (0)