diff options
Diffstat (limited to 'src/lib/async')
-rw-r--r-- | src/lib/async/until.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/async/until.ts b/src/lib/async/until.ts index db53c9218..1b7a57633 100644 --- a/src/lib/async/until.ts +++ b/src/lib/async/until.ts @@ -1,10 +1,10 @@ import {timeout} from './timeout' -export async function until( +export async function until<T>( retries: number, delay: number, - cond: (v: any, err: any) => boolean, - fn: () => Promise<any>, + cond: (v: T, err: any) => boolean, + fn: () => Promise<T>, ): Promise<boolean> { while (retries > 0) { try { @@ -13,7 +13,9 @@ export async function until( return true } } catch (e: any) { - if (cond(undefined, e)) { + // TODO: change the type signature of cond to accept undefined + // however this breaks every existing usage of until -sfn + if (cond(undefined as unknown as T, e)) { return true } } |