diff --git a/packages/toolkit/src/query/fetchBaseQuery.ts b/packages/toolkit/src/query/fetchBaseQuery.ts index e701301506..19c679e339 100644 --- a/packages/toolkit/src/query/fetchBaseQuery.ts +++ b/packages/toolkit/src/query/fetchBaseQuery.ts @@ -105,14 +105,14 @@ function stripUndefined(obj: any) { return copy } -export type FetchBaseQueryArgs = { +export type FetchBaseQueryArgs = { baseUrl?: string prepareHeaders?: ( headers: Headers, api: Pick< BaseQueryApi, 'getState' | 'extra' | 'endpoint' | 'type' | 'forced' - > & { arg: string | FetchArgs; extraOptions: ExtraOptions }, + > & { arg: string | FetchArgs; extraOptions: unknown }, ) => MaybePromise fetchFn?: ( input: RequestInfo, @@ -188,21 +188,8 @@ export type FetchBaseQueryMeta = { request: Request; response?: Response } * @param {number} timeout * A number in milliseconds that represents the maximum time a request can take before timing out. */ -export function fetchBaseQuery(options?: FetchBaseQueryArgs<{}>): BaseQueryFn< -string | FetchArgs, -unknown, -FetchBaseQueryError, -{}, -FetchBaseQueryMeta -> -export function fetchBaseQuery(options?: FetchBaseQueryArgs): BaseQueryFn< -string | FetchArgs, -unknown, -FetchBaseQueryError, -ExtraOptions, -FetchBaseQueryMeta -> -export function fetchBaseQuery({ + +export function fetchBaseQuery({ baseUrl, prepareHeaders = (x) => x, fetchFn = defaultFetchFn, @@ -214,11 +201,11 @@ export function fetchBaseQuery({ responseHandler: globalResponseHandler, validateStatus: globalValidateStatus, ...baseFetchOptions -}: FetchBaseQueryArgs = {}): BaseQueryFn< +}: FetchBaseQueryArgs = {}): BaseQueryFn< string | FetchArgs, unknown, FetchBaseQueryError, - ExtraOptions, + {}, FetchBaseQueryMeta > { if (typeof fetch === 'undefined' && fetchFn === defaultFetchFn) { diff --git a/packages/toolkit/src/query/tests/fetchBaseQuery.test.tsx b/packages/toolkit/src/query/tests/fetchBaseQuery.test.tsx index 81aa17db31..3b70753318 100644 --- a/packages/toolkit/src/query/tests/fetchBaseQuery.test.tsx +++ b/packages/toolkit/src/query/tests/fetchBaseQuery.test.tsx @@ -856,12 +856,9 @@ describe('fetchBaseQuery', () => { test('can be instantiated with a `ExtraOptions` generic and `extraOptions` will be available in `prepareHeaders', async () => { const prepare = vitest.fn() - const baseQuery = fetchBaseQuery<{ foo?: string; bar?: number }>({ + const baseQuery = fetchBaseQuery({ prepareHeaders(headers, api) { - expectTypeOf(api.extraOptions).toEqualTypeOf<{ - foo?: string - bar?: number - }>() + expectTypeOf(api.extraOptions).toEqualTypeOf() prepare.apply(undefined, arguments as unknown as any[]) }, }) @@ -884,8 +881,6 @@ describe('fetchBaseQuery', () => { extraOptions: { foo: 'asd', bar: 1, - // @ts-expect-error - baz: 5, }, }), testMutation: build.mutation({ @@ -897,8 +892,6 @@ describe('fetchBaseQuery', () => { extraOptions: { foo: 'qwe', bar: 15, - // @ts-expect-error - baz: 5, }, }), }