Skip to content

Angular: no type narrowing on infinite query status #8984

Open
@arnoud-dv

Description

@arnoud-dv

Describe the bug

injectQuery and injectMutation support type narrowing via the is* status signals.

This was not implemented for injectInfiniteQuery

Your minimal, reproducible example

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbwFBzsAdgKwKYGMYCKArtlAJ4A0KaWeMAkugGYbAzbGmVIC+cTUCCDgAiAAIwAhugDOU3AGsA9NIDmRADaSoAWgCOJcjuwAPMKVDZ0UjSIDcSUJFiI4RGdkYt0bDobJwfAJCohLScpKKSlDYkTD6-vZISLgQsvBqmtqc5HAAvDQ4+DlkABSlAJT5AHxwpcioBlwA0thkAFxwANoi7HIiALpUjf4AYuidlTVwAAqCIMAeAHQxMhAaAG7YpQCsFVQ8FRUOjkx1mVpQJUuLAMpEuLjYMjKVVQ1wSkpwgKDkcJJMdhQOC4AAWeAUGFUaBk90ezxkcAAJpIpHB0BB4JAXsAAEYaAJEdBI7DebBI1DUVLpZGoyT5f7odSXa4oqSVByoL6oVAAPQA-LxktS5IzmdovKx2CUGRgigxmFK-FxylU8rV6tQmuRWh1uiIwIJ5TJBsM4NqyONJgg4GBJKpsDNtJJhIdph9UDEYEQoOhZvNFtgVs91ltdsdqDwzVLgJINE6HU6oC7OgAmM0OmBzbAbYAQdwJx3OkCTFhQOSFtW1ACMGewMAAcqYs-ai8mS3UtBXW1W4ABmA5HE7AM6lC4SxU+aX+G6wh5PF5vRDUbmAGXJ-oDSCDwYooTC4QvEWz6XJgBoNLaIDj8YTiaSMOSqWlRceGeOoJKp8ryEtjxyV98PICk+NJ2g6iIFMeSxgc8nKfIBfKCjwwrPvAMRxJ+vgygU7ieJOWH+JqIwtG0nQ9IaEDGqaWpjBMdQ2jBSYuoEvYenAXo+n6cxCIGwZrJs2x7HBUbUDGcaFkxHbptQmbZrm+YyBJxalsA5Ytg6va1jJ9ZNiY6ltimnaSN2GnTAOvARqcdTofgmHTlws4Hgi7wAb8G5AtuEJ7nc84IrSaIYliV4yHiBJuHeZIUnAIEvnSDI2Qq3gEQ5x5wdyQGCqgIpYq2EH+ZI0G5WlCFwMByFAA

Steps to reproduce

On linked TS playground:

const infiniteQuery = injectInfiniteQuery(() => ({
  queryKey: ["projects"],
  queryFn: ({ pageParam }) => {
    return Promise.resolve(5);
  },
  initialPageParam: 2,
  getPreviousPageParam: (firstPage) => 1,
  getNextPageParam: (lastPage) => 3,
}));

if (infiniteQuery.isSuccess()) {
  // ❌ after checking isSuccess data signal still possibly undefined
  const data = infiniteQuery.data();
}

Expected behavior

Type narrowing should work for infinite queries on Angular too

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

N/A

Tanstack Query adapter

angular-query

TanStack Query version

v5.72.3

TypeScript version

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions