Open
Description
Describe the bug
After updating TanStack from version 5.61.5 to 5.62.0 (not solved with 5.69.0), I encountered the following TypeScript error on every function that returns queryOptions
or infiniteQueryOptions
:
TS2527: The inferred type of 'queryPlan' references an inaccessible 'unique symbol' type. A type annotation is necessary.
Your minimal, reproducible example
Steps to reproduce
Inside a Angular's service :
public queryOne(exampleId: number) {
return queryOptions({
queryKey: [this.getFetchPath(...)],
queryFn: (): Promise<ExampleDTO[]> => this.getOne(...),
enabled: !!exampleId,
});
}
public queryMany(paramsData) {
return infiniteQueryOptions({
queryKey: [...],
queryFn: (pageParam): Promise<ExampleDTO[]> => this.getMany(...),
...,
});
}
Expected behavior
The code should compile without any TypeScript errors without any type annotation.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: Windows
- Framework: Angular v19.2.2
Tanstack Query adapter
angular-query
TanStack Query version
v5.62.0
TypeScript version
v5.7.3
Additional context
I managed to get rid of this error by annotating queryOptions
and function return type :
public queryMany(...): CreateQueryOptions<ExampleDTO[]> {
return queryOptions<ExampleDTO[]>(...);
}
However, unable to annotate properly infiniteQueryOptions
because I got another type error :
public queryManyWithPagination(...): CreateInfiniteQueryOptions<ExampleDTO[]> {
return infiniteQueryOptions<ExampleDTO[]>(...);
}
TS2322: Type CreateInfiniteQueryOptions<StopPointResponseDTO[], Error, InfiniteData<StopPointResponseDTO[], unknown>, StopPointResponseDTO[], readonly unknown[], unknown> & { ...; } & { ...; } is not assignable to type CreateInfiniteQueryOptions<StopPointResponseDTO[], Error, StopPointResponseDTO[], StopPointResponseDTO[], readonly unknown[], unknown>