Skip to content

Commit 2760f75

Browse files
authored
docs: Update typescript.md for registering types (#6272)
To ensure comprehensive documentation, I have included the import declaration to ensure that everyone is aware that the import is necessary for the module augmentation to function properly. If you omit the import, you will overwrite the entire react-query declaration.
1 parent a320b43 commit 2760f75

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/react/typescript.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ TanStack Query v5 allows for a way to set a global Error type for everything, wi
137137
[//]: # 'RegisterErrorType'
138138

139139
```tsx
140+
import '@tanstack/react-query';
141+
140142
declare module '@tanstack/react-query' {
141143
interface Register {
142144
defaultError: AxiosError
@@ -160,6 +162,8 @@ const { error } = useQuery({ queryKey: ['groups'], queryFn: fetchGroups })
160162
Similarly to registering a [global error type](#registering-a-global-error) you can also register a global `Meta` type. This ensures the optional `meta` field on [queries](./reference/useQuery.md) and [mutations](./reference/useMutation.md) stays consistent and is type-safe.
161163

162164
```ts
165+
import '@tanstack/react-query';
166+
163167
declare module '@tanstack/react-query' {
164168
interface Register {
165169
queryMeta: MyMeta,

0 commit comments

Comments
 (0)