|
1 | 1 | import {expectType} from 'tsd'; |
2 | 2 | import pRetry, {AbortError, type RetryContext} from './index.js'; |
3 | 3 |
|
4 | | -expectType<Promise<number>>( |
5 | | - pRetry(async count => { |
6 | | - expectType<number>(count); |
7 | | - return 1; |
8 | | - }), |
9 | | -); |
10 | | -expectType<Promise<void>>( |
11 | | - pRetry(() => {}, { // eslint-disable-line @typescript-eslint/no-empty-function |
12 | | - onFailedAttempt(context) { |
13 | | - expectType<RetryContext>(context); |
14 | | - expectType<number>(context.attemptNumber); |
15 | | - expectType<number>(context.retriesLeft); |
16 | | - expectType<number>(context.retriesConsumed); |
17 | | - }, |
18 | | - }), |
19 | | -); |
20 | | -expectType<Promise<string>>( |
21 | | - pRetry(() => 'foo', { |
22 | | - retries: 5, |
23 | | - }), |
24 | | -); |
| 4 | +expectType<Promise<number>>(pRetry(async count => { |
| 5 | + expectType<number>(count); |
| 6 | + return 1; |
| 7 | +})); |
| 8 | +expectType<Promise<void>>(pRetry(() => {}, { // eslint-disable-line @typescript-eslint/no-empty-function |
| 9 | + onFailedAttempt(context) { |
| 10 | + expectType<RetryContext>(context); |
| 11 | + expectType<number>(context.attemptNumber); |
| 12 | + expectType<number>(context.retriesLeft); |
| 13 | + expectType<number>(context.retriesConsumed); |
| 14 | + }, |
| 15 | +})); |
| 16 | +expectType<Promise<string>>(pRetry(() => 'foo', { |
| 17 | + retries: 5, |
| 18 | +})); |
25 | 19 |
|
26 | | -expectType<Promise<string>>( |
27 | | - pRetry(async () => 'value', { |
28 | | - async shouldConsumeRetry(context) { |
29 | | - expectType<RetryContext>(context); |
30 | | - expectType<Error>(context.error); |
31 | | - return true; |
32 | | - }, |
33 | | - minTimeout: 0, |
34 | | - }), |
35 | | -); |
| 20 | +expectType<Promise<string>>(pRetry(async () => 'value', { |
| 21 | + async shouldConsumeRetry(context) { |
| 22 | + expectType<RetryContext>(context); |
| 23 | + expectType<Error>(context.error); |
| 24 | + return true; |
| 25 | + }, |
| 26 | + minTimeout: 0, |
| 27 | +})); |
36 | 28 |
|
37 | 29 | const abortError = new AbortError('foo'); |
38 | 30 | new AbortError(new Error('foo')); // eslint-disable-line no-new |
|
0 commit comments