From b64eb4714de2a362db4958f765e2756bf068c4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Dombya?= <135591453+hervedombya@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:57:00 +0200 Subject: [PATCH] fix typing issues with useMutationsHandler --- src/lib/components/toast/useMutationsHandler.test.tsx | 6 +++--- src/lib/components/toast/useMutationsHandler.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/components/toast/useMutationsHandler.test.tsx b/src/lib/components/toast/useMutationsHandler.test.tsx index e6d0dc8d22..8c37c78700 100644 --- a/src/lib/components/toast/useMutationsHandler.test.tsx +++ b/src/lib/components/toast/useMutationsHandler.test.tsx @@ -10,7 +10,7 @@ const mockUseToast = useToast as jest.MockedFunction; const mutationResultMock = { context: undefined, - data: [], + data: ['mockData'], failureCount: 0, error: null, mutate: jest.fn(), @@ -56,7 +56,7 @@ describe('useMutationsHandler', () => { }, name: 'mutation3', }, - ]; + ] as const; const messageDescriptionBuilder = jest.fn(() => 'message'); @@ -129,7 +129,7 @@ describe('useMutationsHandler', () => { }, name: 'mutation4', }, - ]; + ] as const; const { waitFor } = renderHook(() => useMutationsHandler({ diff --git a/src/lib/components/toast/useMutationsHandler.ts b/src/lib/components/toast/useMutationsHandler.ts index 274d2dc27d..156ef4cac7 100644 --- a/src/lib/components/toast/useMutationsHandler.ts +++ b/src/lib/components/toast/useMutationsHandler.ts @@ -43,9 +43,9 @@ declare type MutationsResults< ? [...Result, GetResults] : T extends [infer Head, ...infer Tail] ? MutationsResults<[...Tail], [...Result, GetResults], [...Depth, 1]> - : T extends MutationConfig>[] - ? MutationConfig>[] - : MutationConfig>[]; + : unknown[] extends T + ? T + : never; enum DescriptionBuilderStatus { Success = 'success', @@ -120,7 +120,7 @@ export const useMutationsHandler = < const mutations = [ mainMutation, ...(dependantMutations ? dependantMutations : []), - ]; + ] as MutationConfig>[]; const handleMutationsCompletion = useCallback(async () => { const results = await Promise.all(mutations.map((m) => m.mutation));