You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
// 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: any
this 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; ); );
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
The text was updated successfully, but these errors were encountered:
o-az
changed the title
Svelte: passing a store to createQuery still breaks typescript
Svelte: passing a store to createQuery breaks types when using selectJul 5, 2024
Describe the bug
using the latest version of tanstack query svelte, passing
derived
store and usingselect
to select subset of the data makes thedata
in select typeany
and breaks the query types.Playground link: https://tsplay.dev/mpkn6N
Example. This works:
this doesn't:
this shows that
select
works withoutderived
:Your minimal, reproducible example
https://tsplay.dev/mpkn6N
Steps to reproduce
derived
store,select
in the query,data
type isany
.see twoslash shiki comments
Expected behavior
it should not break types when passing a store and using
select
tocreateQuery
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
The text was updated successfully, but these errors were encountered: