Open yangricardo opened 10 months ago
Today when i have updated the @tanstack/react-query depenency, i found out that the latest compatible version is 5.13.4.
Changing the generated local code from:
ts function useRapiniMutation<TData = unknown, TError = unknown, TVariables = void, TContext = unknown>(mutationFn: MutationFunction<TData, TVariables>, config?: (queryClient: QueryClient) => Pick<UseMutationOptions<TData, TError, TVariables, TContext>, "onSuccess" | "onSettled" | "onError">, options?: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, "mutationFn">): UseMutationResult<TData, TError, TVariables, TContext> { const { onSuccess, onError, onSettled, ...rest } = options ?? {}; const queryClient = useQueryClient(); const conf = config?.(queryClient); const mutationOptions: typeof options = { onSuccess: (data: TData, variables: TVariables, context?: TContext) => { conf?.onSuccess?.(data, variables, context); onSuccess?.(data, variables, context); }, onError: (error: TError, variables: TVariables, context?: TContext) => { conf?.onError?.(error, variables, context); onError?.(error, variables, context); }, onSettled: (data: TData | undefined, error: TError | null, variables: TVariables, context?: TContext) => { conf?.onSettled?.(data, error, variables, context); onSettled?.(data, error, variables, context); }, ...rest }; return useMutation({ mutationFn, ...mutationOptions }); }
to
ts function useRapiniMutation<TData = unknown, TError = unknown, TVariables = void, TContext = unknown>(mutationFn: MutationFunction<TData, TVariables>, config?: (queryClient: QueryClient) => Pick<UseMutationOptions<TData, TError, TVariables, TContext>, "onSuccess" | "onSettled" | "onError">, options?: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, "mutationFn">): UseMutationResult<TData, TError, TVariables, TContext> { const { onSuccess, onError, onSettled, ...rest } = options ?? {}; const queryClient = useQueryClient(); const conf = config?.(queryClient); const mutationOptions: typeof options = { onSuccess: (data: TData, variables: TVariables, context: TContext) => { conf?.onSuccess?.(data, variables, context); onSuccess?.(data, variables, context); }, onError: (error: TError, variables: TVariables, context?: TContext) => { conf?.onError?.(error, variables, context); onError?.(error, variables, context); }, onSettled: (data: TData | undefined, error: TError | null, variables: TVariables, context?: TContext) => { conf?.onSettled?.(data, error, variables, context); onSettled?.(data, error, variables, context); }, ...rest }; return useMutation({ mutationFn, ...mutationOptions }); }
makes it compile again:
onSuccess: (data: TData, variables: TVariables, context: TContext) => { conf?.onSuccess?.(data, variables, context); onSuccess?.(data, variables, context); },
Hey @yangricardo, thanks for opening the issue. I won't have much time for awhile to look into this, but if you or anyone else wants to open a PR, I will gladly review
Today when i have updated the @tanstack/react-query depenency, i found out that the latest compatible version is 5.13.4.
Changing the generated local code from:
ts function useRapiniMutation<TData = unknown, TError = unknown, TVariables = void, TContext = unknown>(mutationFn: MutationFunction<TData, TVariables>, config?: (queryClient: QueryClient) => Pick<UseMutationOptions<TData, TError, TVariables, TContext>, "onSuccess" | "onSettled" | "onError">, options?: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, "mutationFn">): UseMutationResult<TData, TError, TVariables, TContext> { const { onSuccess, onError, onSettled, ...rest } = options ?? {}; const queryClient = useQueryClient(); const conf = config?.(queryClient); const mutationOptions: typeof options = { onSuccess: (data: TData, variables: TVariables, context?: TContext) => { conf?.onSuccess?.(data, variables, context); onSuccess?.(data, variables, context); }, onError: (error: TError, variables: TVariables, context?: TContext) => { conf?.onError?.(error, variables, context); onError?.(error, variables, context); }, onSettled: (data: TData | undefined, error: TError | null, variables: TVariables, context?: TContext) => { conf?.onSettled?.(data, error, variables, context); onSettled?.(data, error, variables, context); }, ...rest }; return useMutation({ mutationFn, ...mutationOptions }); }
to
ts function useRapiniMutation<TData = unknown, TError = unknown, TVariables = void, TContext = unknown>(mutationFn: MutationFunction<TData, TVariables>, config?: (queryClient: QueryClient) => Pick<UseMutationOptions<TData, TError, TVariables, TContext>, "onSuccess" | "onSettled" | "onError">, options?: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, "mutationFn">): UseMutationResult<TData, TError, TVariables, TContext> { const { onSuccess, onError, onSettled, ...rest } = options ?? {}; const queryClient = useQueryClient(); const conf = config?.(queryClient); const mutationOptions: typeof options = { onSuccess: (data: TData, variables: TVariables, context: TContext) => { conf?.onSuccess?.(data, variables, context); onSuccess?.(data, variables, context); }, onError: (error: TError, variables: TVariables, context?: TContext) => { conf?.onError?.(error, variables, context); onError?.(error, variables, context); }, onSettled: (data: TData | undefined, error: TError | null, variables: TVariables, context?: TContext) => { conf?.onSettled?.(data, error, variables, context); onSettled?.(data, error, variables, context); }, ...rest }; return useMutation({ mutationFn, ...mutationOptions }); }
makes it compile again: