From 43a8773f792beff6975e50f97a1d5cc26491cd44 Mon Sep 17 00:00:00 2001 From: Logan Wishart-Craig <89035627+logancameo@users.noreply.github.com> Date: Mon, 27 Jun 2022 16:48:50 -0700 Subject: [PATCH] fix(common): NextStep and selectNext async typing updates --- packages/common/src/wizard/select-next.d.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/common/src/wizard/select-next.d.ts b/packages/common/src/wizard/select-next.d.ts index 3bc0316f3..16e66d333 100644 --- a/packages/common/src/wizard/select-next.d.ts +++ b/packages/common/src/wizard/select-next.d.ts @@ -1,6 +1,10 @@ import { AnyObject } from "@data-driven-forms/react-form-renderer"; -export type NextStep = string | ((values: AnyObject) => string) | AnyObject & { +export type NextStepContext = { + values: AnyObject; +} + +export type NextStep = string | ((context: NextStepContext) => string) | ((context: NextStepContext) => Promise) | AnyObject & { stepMapper: { [key: string]: string; [key: number]: string; @@ -8,5 +12,5 @@ export type NextStep = string | ((values: AnyObject) => string) | AnyObject & { when: string[] | string } -declare const selectNext: (nextStep: NextStep, getState: (() => AnyObject & {values: AnyObject})) => string; +declare const selectNext: (nextStep: T, getState: (() => AnyObject & {values: AnyObject})) => T extends (...args: any[]) => infer U ? U : string; export default selectNext;