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
Copy file name to clipboardExpand all lines: docs/framework/angular/typescript.md
+85-1Lines changed: 85 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,6 @@ replace:
12
12
'React Query': 'TanStack Query',
13
13
'`success`': '`isSuccess()`',
14
14
'function:': 'function.',
15
-
'separate function': 'separate function or a service',
16
15
}
17
16
---
18
17
@@ -170,5 +169,90 @@ computed(() => {
170
169
```
171
170
172
171
[//]: #'RegisterErrorType'
172
+
[//]: #'TypingQueryOptions'
173
+
174
+
## Typing Query Options
175
+
176
+
If you inline query options into `injectQuery`, you'll get automatic type inference. However, you might want to extract the query options into a separate function to share them between `injectQuery` and e.g. `prefetchQuery` or manage them in a service. In that case, you'd lose type inference. To get it back, you can use the `queryOptions` helper:
Further, the `queryKey` returned from `queryOptions` knows about the `queryFn` associated with it, and we can leverage that type information to make functions like `queryClient.getQueryData` aware of those types as well:
0 commit comments