amis-rpc-design/node_modules/@reduxjs/toolkit/dist/query/react/namedHooks.d.ts
2023-10-07 19:42:30 +08:00

14 lines
897 B
TypeScript

import type { UseMutation, UseLazyQuery, UseQuery } from './buildHooks';
import type { DefinitionType, EndpointDefinitions, MutationDefinition, QueryDefinition } from '@reduxjs/toolkit/query';
export declare type HooksWithUniqueNames<Definitions extends EndpointDefinitions> = keyof Definitions extends infer Keys ? Keys extends string ? Definitions[Keys] extends {
type: DefinitionType.query;
} ? {
[K in Keys as `use${Capitalize<K>}Query`]: UseQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
} & {
[K in Keys as `useLazy${Capitalize<K>}Query`]: UseLazyQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
} : Definitions[Keys] extends {
type: DefinitionType.mutation;
} ? {
[K in Keys as `use${Capitalize<K>}Mutation`]: UseMutation<Extract<Definitions[K], MutationDefinition<any, any, any, any>>>;
} : never : never : never;