Describe the bug
using the latest version of tanstack query svelte, passing derived store and using select to select subset of the data makes the data in select type any and breaks the query types.
Playground link: https://tsplay.dev/mpkn6N
Example. This works:
// query type works as expectedconstqueryThatWorks=createQuery(derived(intervalMs,($intervalMs)=>({queryKey: ["refetch"],queryFn: async()=>({a: {b: {c: ""}}}),refetchInterval: $intervalMs,})),);constresult1=get(queryThatWorks)?.data;// ^? const result: {a: Eb: { c: string; 3; };..this doesn't:
// `select` data is type anyconstqueryWithBrokenTypes=createQuery(derived(intervalMs,($intervalMs)=>({queryKey: ["refetch"],queryFn: async()=>({a: {b: {c: ""}}}),refetchInterval: $intervalMs,// data type is any, never inferredselect: (data)=>data,// ^? (parameter) data: any})),);constresult2=get(queryWithBrokenTypes)?.data;// ^? const result2: anythis shows that select works without derived:
// `select` works without `derived`constqueryWithSelectWorks=createQuery({queryKey: ["refetch"],queryFn: async()=>({a: {b: {c: ""}}}),// data type is any, never inferredselect: (data)=>data,// ^? (parameter) data: {a: {b: { c: string; ) ;..});constresult3=get(queryWithSelectWorks)?.data;// ^? const result3: { a: {b: (c: string; ); );Your minimal, reproducible example
https://tsplay.dev/mpkn6N
Steps to reproduce
- create a query in svelte,
- pass a
derived store, - use
select in the query, - notice how
data type is any.
see twoslash shiki comments
Expected behavior
it should not break types when passing a store and using select to createQuery
How often does this bug happen?
Every time
Screenshots or Videos

Platform
all
Tanstack Query adapter
svelte-query
TanStack Query version
^5.49.1
TypeScript version
6.5.2
Additional context
No response
Describe the bug
using the latest version of tanstack query svelte, passing
derivedstore and usingselectto select subset of the data makes thedatain select typeanyand breaks the query types.Playground link: https://tsplay.dev/mpkn6N
Example. This works:
this doesn't:
this shows that
selectworks withoutderived:Your minimal, reproducible example
https://tsplay.dev/mpkn6N
Steps to reproduce
derivedstore,selectin the query,datatype isany.see twoslash shiki comments
Expected behavior
it should not break types when passing a store and using
selecttocreateQueryHow often does this bug happen?
Every time
Screenshots or Videos
Platform
all
Tanstack Query adapter
svelte-query
TanStack Query version
^5.49.1
TypeScript version
6.5.2
Additional context
No response