TypeScript type hinting fails
I have followed the example shown in https://tanstack.com/query/latest/docs/svelte/ssr to a T, but I cannot get the type hint for the Readable result.
2nd picture shows my expectation for $query
SSR and SvelteKit | TanStack Query Docs
Setup
SvelteKit defaults to rendering routes with SSR. Because of this, you need to disable the query on the server. Otherwise, your query will continue executing on the server asynchronously, even after the HTML has been sent to the client.


13 Replies
other-emerald•3y ago
@Deleted User use $query (svelte store syntax) instead of query.subscribe 🙂
rival-blackOP•3y ago
thanks for responding! I get, in <script> picture 1, and in html picture 2


other-emerald•3y ago
Hmmm I'll need a bit more info. Can you either share a pic of the whole file or make a repro?
rival-blackOP•3y ago
naturally, this will not run, but it should be sufficient for my issue i hope?
rival-blackOP•3y ago
i am using webstorm 2023.1.1
other-emerald•3y ago
Looks fine to me
Maybe I need to update the docs
You can access data on $query.data
But you need to do something like {#if $query.isSuccess} first
rival-blackOP•3y ago
oh, it works, i'm just not getting the type hints
other-emerald•3y ago
Actually check out the examples folder: https://github.com/TanStack/query/tree/main/examples/svelte
GitHub
query/examples/svelte at main · TanStack/query
🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query. - query/examples/svelte at main · TanSta...
rival-blackOP•3y ago
very perfect

other-emerald•3y ago
I know in the past webstorm didn't work well with svelte, has that changed?
rival-blackOP•3y ago
it could be webstorm i suppose
i've heard complaints, but haven't really been troubled by anything until now
other-emerald•3y ago
Something as simple as svelte stores should be supported
rival-blackOP•3y ago
let me actually try invalidating the cache
that wasn't it. i'll try on vscode. is that what you use?
works in vscode, so its a webstorm issue it turns out