From 335a6ce3b180f162efbb744c0b7c298890aa24bf Mon Sep 17 00:00:00 2001 From: EskiMojo14 Date: Sat, 27 Jan 2024 19:40:11 +0000 Subject: [PATCH] Revert "try something" This reverts commit 389d5bc86bad1d34d2d189188a0821c173beb27b. --- packages/toolkit/src/query/createApi.ts | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/toolkit/src/query/createApi.ts b/packages/toolkit/src/query/createApi.ts index 0159588f1..ed22f4ec9 100644 --- a/packages/toolkit/src/query/createApi.ts +++ b/packages/toolkit/src/query/createApi.ts @@ -17,7 +17,7 @@ export interface CreateApiOptions< BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string = 'api', - TagTypes extends string = never, + TagTypes extends string = never > { /** * The base query used by each endpoint if no `queryFn` option is specified. RTK Query exports a utility called [fetchBaseQuery](./fetchBaseQuery) as a lightweight wrapper around `fetch` for common use-cases. See [Customizing Queries](../../rtk-query/usage/customizing-queries) if `fetchBaseQuery` does not handle your requirements. @@ -97,7 +97,7 @@ export interface CreateApiOptions< * Endpoints are just a set of operations that you want to perform against your server. You define them as an object using the builder syntax. There are two basic endpoint types: [`query`](../../rtk-query/usage/queries) and [`mutation`](../../rtk-query/usage/mutations). */ endpoints( - build: EndpointBuilder, + build: EndpointBuilder ): Definitions /** * Defaults to `60` _(this value is in seconds)_. This is how long RTK Query will keep your data cached for **after** the last component unsubscribes. For example, if you query an endpoint, then unmount the component, then mount another component that makes the same request within the given time frame, the most recent value will be served from the cache. @@ -200,7 +200,7 @@ export interface CreateApiOptions< reducerPath, }: { reducerPath: ReducerPath - }, + } ) => | undefined | CombinedState< @@ -220,9 +220,9 @@ export type CreateApi = { BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string = 'api', - TagTypes extends string = never, + TagTypes extends string = never >( - options: CreateApiOptions, + options: CreateApiOptions ): Api } @@ -249,14 +249,14 @@ export type CreateApi = { * @param modules - A variable number of modules that customize how the `createApi` method handles endpoints * @returns A `createApi` method using the provided `modules`. */ -export function buildCreateApi( - ...modules: [...{ [K in keyof Modules]: Module }] -): CreateApi { +export function buildCreateApi, ...Module[]]>( + ...modules: Modules +): CreateApi { return function baseCreateApi(options) { const extractRehydrationInfo = weakMapMemoize((action: UnknownAction) => options.extractRehydrationInfo?.(action, { reducerPath: (options.reducerPath ?? 'api') as any, - }), + }) ) const optionsWithDefaults: CreateApiOptions = { @@ -305,7 +305,7 @@ export function buildCreateApi( apiUid: nanoid(), extractRehydrationInfo, hasRehydrationInfo: weakMapMemoize( - (action) => extractRehydrationInfo(action) != null, + (action) => extractRehydrationInfo(action) != null ), } @@ -321,14 +321,14 @@ export function buildCreateApi( } if (endpoints) { for (const [endpointName, partialDefinition] of Object.entries( - endpoints, + endpoints )) { if (typeof partialDefinition === 'function') { partialDefinition(context.endpointDefinitions[endpointName]) } else { Object.assign( context.endpointDefinitions[endpointName] || {}, - partialDefinition, + partialDefinition ) } } @@ -338,19 +338,19 @@ export function buildCreateApi( } as Api const initializedModules = modules.map((m) => - m.init(api as any, optionsWithDefaults as any, context), + m.init(api as any, optionsWithDefaults as any, context) ) function injectEndpoints( - inject: Parameters[0], + inject: Parameters[0] ) { const evaluatedEndpoints = inject.endpoints({ - query: (x) => ({ ...x, type: DefinitionType.query }) as any, - mutation: (x) => ({ ...x, type: DefinitionType.mutation }) as any, + query: (x) => ({ ...x, type: DefinitionType.query } as any), + mutation: (x) => ({ ...x, type: DefinitionType.mutation } as any), }) for (const [endpointName, definition] of Object.entries( - evaluatedEndpoints, + evaluatedEndpoints )) { if ( !inject.overrideExisting && @@ -361,7 +361,7 @@ export function buildCreateApi( process.env.NODE_ENV === 'development' ) { console.error( - `called \`injectEndpoints\` to override already-existing endpointName ${endpointName} without specifying \`overrideExisting: true\``, + `called \`injectEndpoints\` to override already-existing endpointName ${endpointName} without specifying \`overrideExisting: true\`` ) }