Register
定义位置:packages/query-core/src/types.ts:71
该接口用于通过声明合并(declaration merging)来全局覆盖 Query 的默认类型。
其每个字段均会替换对应类型的默认定义:defaultError 替换 DefaultError,queryKey 替换 QueryKey,mutationKey 替换 MutationKey,queryMeta 替换 QueryMeta,
以及 mutationMeta 替换 MutationMeta。若省略某个字段,则该类型继续使用默认定义。
请对实际安装的模块进行增强 —— @tanstack/react-query、@tanstack/vue-query、@tanstack/solid-query、@tanstack/svelte-query、@tanstack/preact-query、@tanstack/angular-query-experimental 或 @tanstack/lit-query。对 @tanstack/query-core 进行增强同样有效,且可一次性覆盖所有适配器。
示例
TypeScript
1// Use the module you installed — here, the React adapter.2declare module '@tanstack/react-query' {3 interface Register {4 defaultError: AxiosError5 }6}