UNPKG

1.82 kBTypeScriptView Raw
1import type { ThunkDispatch } from '@reduxjs/toolkit';
2import type { MaybePromise, UnwrapPromise } from './tsHelpers';
3export interface BaseQueryApi {
4 signal: AbortSignal;
5 dispatch: ThunkDispatch<any, any, any>;
6 getState: () => unknown;
7 extra: unknown;
8}
9export declare type QueryReturnValue<T = unknown, E = unknown, M = unknown> = {
10 error: E;
11 data?: undefined;
12 meta?: M;
13} | {
14 error?: undefined;
15 data: T;
16 meta?: M;
17};
18export declare type BaseQueryFn<Args = any, Result = unknown, Error = unknown, DefinitionExtraOptions = {}, Meta = {}> = (args: Args, api: BaseQueryApi, extraOptions: DefinitionExtraOptions) => MaybePromise<QueryReturnValue<Result, Error, Meta>>;
19export declare type BaseQueryEnhancer<AdditionalArgs = unknown, AdditionalDefinitionExtraOptions = unknown, Config = void> = <BaseQuery extends BaseQueryFn>(baseQuery: BaseQuery, config: Config) => BaseQueryFn<BaseQueryArg<BaseQuery> & AdditionalArgs, BaseQueryResult<BaseQuery>, BaseQueryError<BaseQuery>, BaseQueryExtraOptions<BaseQuery> & AdditionalDefinitionExtraOptions>;
20export declare type BaseQueryResult<BaseQuery extends BaseQueryFn> = UnwrapPromise<ReturnType<BaseQuery>> extends infer Unwrapped ? Unwrapped extends {
21 data: any;
22} ? Unwrapped['data'] : never : never;
23export declare type BaseQueryMeta<BaseQuery extends BaseQueryFn> = UnwrapPromise<ReturnType<BaseQuery>>['meta'];
24export declare type BaseQueryError<BaseQuery extends BaseQueryFn> = Exclude<UnwrapPromise<ReturnType<BaseQuery>>, {
25 error?: undefined;
26}>['error'];
27export declare type BaseQueryArg<T extends (arg: any, ...args: any[]) => any> = T extends (arg: infer A, ...args: any[]) => any ? A : any;
28export declare type BaseQueryExtraOptions<BaseQuery extends BaseQueryFn> = Parameters<BaseQuery>[2];