Skip to content

Commit

Permalink
fix typing issues with useMutationsHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
hervedombya committed Oct 25, 2023
1 parent 52ef758 commit b64eb47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/lib/components/toast/useMutationsHandler.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const mockUseToast = useToast as jest.MockedFunction<typeof useToast>;

const mutationResultMock = {
context: undefined,
data: [],
data: ['mockData'],
failureCount: 0,
error: null,
mutate: jest.fn(),
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('useMutationsHandler', () => {
},
name: 'mutation3',
},
];
] as const;

const messageDescriptionBuilder = jest.fn(() => 'message');

Expand Down Expand Up @@ -129,7 +129,7 @@ describe('useMutationsHandler', () => {
},
name: 'mutation4',
},
];
] as const;

const { waitFor } = renderHook(() =>
useMutationsHandler({
Expand Down
8 changes: 4 additions & 4 deletions src/lib/components/toast/useMutationsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ declare type MutationsResults<
? [...Result, GetResults<Head>]
: T extends [infer Head, ...infer Tail]
? MutationsResults<[...Tail], [...Result, GetResults<Head>], [...Depth, 1]>
: T extends MutationConfig<MinimalMutationResult<infer TData, infer TError>>[]
? MutationConfig<MinimalMutationResult<TData, TError>>[]
: MutationConfig<MinimalMutationResult<unknown, unknown>>[];
: unknown[] extends T
? T
: never;

enum DescriptionBuilderStatus {
Success = 'success',
Expand Down Expand Up @@ -120,7 +120,7 @@ export const useMutationsHandler = <
const mutations = [
mainMutation,
...(dependantMutations ? dependantMutations : []),
];
] as MutationConfig<MinimalMutationResult<unknown, unknown>>[];

const handleMutationsCompletion = useCallback(async () => {
const results = await Promise.all(mutations.map((m) => m.mutation));
Expand Down

0 comments on commit b64eb47

Please sign in to comment.