From a30099157aa6d24d4fdcaf35f457210a4f14f470 Mon Sep 17 00:00:00 2001 From: BluJ Date: Thu, 18 Aug 2022 08:38:38 -0600 Subject: [PATCH] fix: Type to include promise --- compat/migrations.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/compat/migrations.ts b/compat/migrations.ts index 303cc1c..fac5034 100644 --- a/compat/migrations.ts +++ b/compat/migrations.ts @@ -19,18 +19,18 @@ export interface NoRepeat { export function updateConfig< version extends string, type extends "up" | "down", ->( - fn: (config: T.Config, effects: T.Effects) => T.Config, - configured: boolean, - noRepeat?: NoRepeat, - noFail = false, + >( + fn: (config: T.Config, effects: T.Effects) => T.Config | Promise, + configured: boolean, + noRepeat?: NoRepeat, + noFail = false, ): M.MigrationFn { return M.migrationFn(async (effects: T.Effects) => { await noRepeatGuard(effects, noRepeat, async () => { let config = util.unwrapResultType(await getConfig({})(effects)).config; if (config) { try { - config = fn(config, effects); + config = await fn(config, effects); } catch (e) { if (!noFail) { throw e; @@ -48,10 +48,10 @@ export function updateConfig< export async function noRepeatGuard< version extends string, type extends "up" | "down", ->( - effects: T.Effects, - noRepeat: NoRepeat | undefined, - fn: () => Promise, + >( + effects: T.Effects, + noRepeat: NoRepeat | undefined, + fn: () => Promise, ): Promise { if (!noRepeat) { return fn();