Major type inference difference in templates between VS Code and WebStorm
Hey there. We've been using the library quite successfully and honestly it's been a bliss.
The issue I have is actually not with TanStack but WebStorm. I've been experiencing a major difference with type inference inside templates between VSCode and WebStorm. And I'm curious if it's just me or it's a bigger issue with WebStorm.
Type narrowing in WebStorm seems to be broken
Inside WebStorm the return type of
However, the same snippet inside VS code produces
If you try to use
For example a query like this
It fails to narrow down the type of
Again, the VS code has no issue with the same snippet.
The version of WebStorm is
I run them on the same TypeScript version, I tried to clean the cache inside WebStorm but no luck.
So the question is, what could cause the difference? And I'm slightly worried that if the issue issue is not only on my PC, the newcomers to the library might actually think that there's something wrong with the library, and not WebStorm just failing to properly infer the types.
The issue I have is actually not with TanStack but WebStorm. I've been experiencing a major difference with type inference inside templates between VSCode and WebStorm. And I'm curious if it's just me or it's a bigger issue with WebStorm.
Type narrowing in WebStorm seems to be broken
Inside WebStorm the return type of
data() is () => ( Todo | undefined )However, the same snippet inside VS code produces
() => Todo If you try to use
queryOptions inside WebStorm it gets even worse.For example a query like this
It fails to narrow down the type of
query.data() (see the screenshot). And if you try to assign it to a variable like @let data = query.data() the type will be anyAgain, the VS code has no issue with the same snippet.
The version of WebStorm is
WebStorm 2024.3.5 and VS code - Version: 1.98.1 (Universal) both running on Mac.I run them on the same TypeScript version, I tried to clean the cache inside WebStorm but no luck.
So the question is, what could cause the difference? And I'm slightly worried that if the issue issue is not only on my PC, the newcomers to the library might actually think that there's something wrong with the library, and not WebStorm just failing to properly infer the types.
