Skip to content

Commit c66177a

Browse files
committed
docs(vue-query): add example code for Registering a global Error
Signed-off-by: leesb971204 <[email protected]>
1 parent b675c8d commit c66177a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎docs/framework/vue/typescript.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ if (error.value instanceof Error) {
8989
[//]: # 'TypingError3'
9090
[//]: # 'TypingError3'
9191
[//]: # 'RegisterErrorType'
92+
93+
```tsx
94+
import '@tanstack/vue-query'
95+
96+
declare module '@tanstack/vue-query' {
97+
interface Register {
98+
// Use unknown so call sites must narrow explicitly.
99+
defaultError: unknown
100+
}
101+
}
102+
103+
const { error } = useQuery({ queryKey: ['groups'], queryFn: fetchGroups })
104+
// ^? const error: unknown | null
105+
```
106+
92107
[//]: # 'RegisterErrorType'
93108
[//]: # 'TypingMeta'
94109
[//]: # 'TypingMeta'

0 commit comments

Comments
 (0)