Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular injectMutation: onSuccess loses type when queryClient is passed to injectMutation #8042

Open
7schmiede opened this issue Sep 11, 2024 · 0 comments

Comments

@7schmiede
Copy link

Describe the bug

When the queryClient is passed in the injectMutation method, the return type of mutationFn is lost in the onSuccess method.

Your minimal, reproducible example

https://stackblitz.com/edit/stackblitz-starters-3zsk2e?file=test.ts

Steps to reproduce

import { injectMutation } from "@tanstack/angular-query-experimental";

// without queryClient 
export const foo = injectMutation(() => ({
    mutationFn: () => Promise.resolve({ foo: true }),
    onSuccess: (result) => {
        result.foo; // result: { foo: boolean; }
    }
}));

// with queryClient
export const bar = injectMutation((queryClient) => ({
    mutationFn: () => Promise.resolve({ bar: true }),
    onSuccess: (result) => {
        result.bar; // result: unknown
    }
}));

Expected behavior

Even if the queryClient is passed, the return type of the mutationFn should remain in the onSuccess method.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Windows 11
  • Browser: Edge Chromium
  • Version: 5.55.4

Tanstack Query adapter

angular-query

TanStack Query version

v5.55.4

TypeScript version

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant