Skip to content

Angular: no type narrowing on infinite query status #8984

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

Open
arnoud-dv opened this issue Apr 9, 2025 · 2 comments · May be fixed by #9016
Open

Angular: no type narrowing on infinite query status #8984

arnoud-dv opened this issue Apr 9, 2025 · 2 comments · May be fixed by #9016

Comments

@arnoud-dv
Copy link
Collaborator

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

@gs18004
Copy link
Contributor

gs18004 commented Apr 14, 2025

Can I work on this one?

@arnoud-dv
Copy link
Collaborator Author

Of course! Thanks for the PR.

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

Successfully merging a pull request may close this issue.

2 participants