TanStack / query

🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.
https://tanstack.com/query
MIT License
40.31k stars 2.7k forks source link

[angular] isPending type isn't typed as Signal #7401

Open k3nsei opened 3 weeks ago

k3nsei commented 3 weeks ago

Describe the bug

When I want to use isPending from mutation I'm getting wrong type. It's returning calculated signal but type is wrongly resolved to boolean. It's also happening to some other properties but I'm using only isPending in my project also I don't remember what others were that weren't working correctly.

Your minimal, reproducible example

https://stackblitz.com/edit/stackblitz-starters-1t77xr?file=src%2Fmain.ts

Steps to reproduce

import { Injectable, Signal } from "@angular/core";
import { injectMutation } from "@tanstack/angular-query-experimental";

@Injectable()
export class Service {
  protected readonly mutation = injectMutation(() => ({
    mutationFn: () => Promise.resolve({}),
  }));

  // TypeScript Error: `boolean` is not assignable to type `Signal<boolean>`
  public readonly isProcessing: Signal<boolean> = this.mutation.isPending;
}

Expected behavior

isPending should be resolved to type Signal<boolean>

How often does this bug happen?

Every time

Screenshots or Videos

image

Platform

Tanstack Query adapter

angular-query

TanStack Query version

v5.35.3

TypeScript version

v5.4.5

Additional context

No response