Describe the bug
Hello,
since #10452 (v5.98.0) the queryOptions helper function does not work with non-getter enabled properties anymore.
I think I am running into the problem mentioned by CodeRabbit in the PR:
#10452 (comment)
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-query-dd82rg7b?file=src%2Fmain.ts
Steps to reproduce
This code throws a typescript error:
function createDefaultQueryOptions() {
const enabled = computed(() => true);
return queryOptions({
queryKey: ['key'],
queryFn: () => Promise.resolve(1),
enabled,
});
}
// Throws "Object literal may only specify known properties, and 'queryKey' does not exist in type '() => UndefinedInitialQueryOptions_alias_1<unknown, Error, unknown, readonly unknown[]>'.ts(2769)"
If I change the code to pass a getter as enabled or remove enabled from the options, it works again:
function createDefaultQueryOptions() {
return queryOptions({
queryKey: ['key'],
queryFn: () => Promise.resolve(1),
enabled: () => true, // getter or remove from options
});
}
Expected behavior
It should work with non-getter enabled, e.g. with computed properties to allow dependent queries as described here.
How often does this bug happen?
Every time
Screenshots or Videos
Platform
- OS: MacOs
- Chrome 146.0.7680.178
Tanstack Query adapter
vue-query
TanStack Query version
v5.99.0
TypeScript version
v6.0.2
Additional context
No response
Describe the bug
Hello,
since #10452 (v5.98.0) the
queryOptionshelper function does not work with non-getterenabledproperties anymore.I think I am running into the problem mentioned by CodeRabbit in the PR:
#10452 (comment)
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-query-dd82rg7b?file=src%2Fmain.ts
Steps to reproduce
This code throws a typescript error:
If I change the code to pass a getter as
enabledor removeenabledfrom the options, it works again:Expected behavior
It should work with non-getter
enabled, e.g. with computed properties to allow dependent queries as described here.How often does this bug happen?
Every time
Screenshots or Videos
Platform
Tanstack Query adapter
vue-query
TanStack Query version
v5.99.0
TypeScript version
v6.0.2
Additional context
No response