@@ -17,7 +17,7 @@ export interface CreateApiOptions<
17
17
BaseQuery extends BaseQueryFn ,
18
18
Definitions extends EndpointDefinitions ,
19
19
ReducerPath extends string = 'api' ,
20
- TagTypes extends string = never
20
+ TagTypes extends string = never ,
21
21
> {
22
22
/**
23
23
* 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<
97
97
* 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).
98
98
*/
99
99
endpoints (
100
- build : EndpointBuilder < BaseQuery , TagTypes , ReducerPath >
100
+ build : EndpointBuilder < BaseQuery , TagTypes , ReducerPath > ,
101
101
) : Definitions
102
102
/**
103
103
* 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<
200
200
reducerPath,
201
201
} : {
202
202
reducerPath : ReducerPath
203
- }
203
+ } ,
204
204
) =>
205
205
| undefined
206
206
| CombinedState <
@@ -220,9 +220,9 @@ export type CreateApi<Modules extends ModuleName> = {
220
220
BaseQuery extends BaseQueryFn ,
221
221
Definitions extends EndpointDefinitions ,
222
222
ReducerPath extends string = 'api' ,
223
- TagTypes extends string = never
223
+ TagTypes extends string = never ,
224
224
> (
225
- options : CreateApiOptions < BaseQuery , Definitions , ReducerPath , TagTypes >
225
+ options : CreateApiOptions < BaseQuery , Definitions , ReducerPath , TagTypes > ,
226
226
) : Api < BaseQuery , Definitions , ReducerPath , TagTypes , Modules >
227
227
}
228
228
@@ -249,14 +249,14 @@ export type CreateApi<Modules extends ModuleName> = {
249
249
* @param modules - A variable number of modules that customize how the `createApi` method handles endpoints
250
250
* @returns A `createApi` method using the provided `modules`.
251
251
*/
252
- export function buildCreateApi < Modules extends [ Module < any > , ...Module < any > [ ] ] > (
253
- ...modules : Modules
254
- ) : CreateApi < Modules [ number ] [ 'name' ] > {
252
+ export function buildCreateApi < Modules extends [ any , ...any [ ] ] > (
253
+ ...modules : [ ... { [ K in keyof Modules ] : Module < Modules [ K ] > } ]
254
+ ) : CreateApi < Modules [ number ] > {
255
255
return function baseCreateApi ( options ) {
256
256
const extractRehydrationInfo = weakMapMemoize ( ( action : UnknownAction ) =>
257
257
options . extractRehydrationInfo ?.( action , {
258
258
reducerPath : ( options . reducerPath ?? 'api' ) as any ,
259
- } )
259
+ } ) ,
260
260
)
261
261
262
262
const optionsWithDefaults : CreateApiOptions < any , any , any , any > = {
@@ -305,7 +305,7 @@ export function buildCreateApi<Modules extends [Module<any>, ...Module<any>[]]>(
305
305
apiUid : nanoid ( ) ,
306
306
extractRehydrationInfo,
307
307
hasRehydrationInfo : weakMapMemoize (
308
- ( action ) => extractRehydrationInfo ( action ) != null
308
+ ( action ) => extractRehydrationInfo ( action ) != null ,
309
309
) ,
310
310
}
311
311
@@ -321,14 +321,14 @@ export function buildCreateApi<Modules extends [Module<any>, ...Module<any>[]]>(
321
321
}
322
322
if ( endpoints ) {
323
323
for ( const [ endpointName , partialDefinition ] of Object . entries (
324
- endpoints
324
+ endpoints ,
325
325
) ) {
326
326
if ( typeof partialDefinition === 'function' ) {
327
327
partialDefinition ( context . endpointDefinitions [ endpointName ] )
328
328
} else {
329
329
Object . assign (
330
330
context . endpointDefinitions [ endpointName ] || { } ,
331
- partialDefinition
331
+ partialDefinition ,
332
332
)
333
333
}
334
334
}
@@ -338,19 +338,19 @@ export function buildCreateApi<Modules extends [Module<any>, ...Module<any>[]]>(
338
338
} as Api < BaseQueryFn , { } , string , string , Modules [ number ] [ 'name' ] >
339
339
340
340
const initializedModules = modules . map ( ( m ) =>
341
- m . init ( api as any , optionsWithDefaults as any , context )
341
+ m . init ( api as any , optionsWithDefaults as any , context ) ,
342
342
)
343
343
344
344
function injectEndpoints (
345
- inject : Parameters < typeof api . injectEndpoints > [ 0 ]
345
+ inject : Parameters < typeof api . injectEndpoints > [ 0 ] ,
346
346
) {
347
347
const evaluatedEndpoints = inject . endpoints ( {
348
- query : ( x ) => ( { ...x , type : DefinitionType . query } as any ) ,
349
- mutation : ( x ) => ( { ...x , type : DefinitionType . mutation } as any ) ,
348
+ query : ( x ) => ( { ...x , type : DefinitionType . query } ) as any ,
349
+ mutation : ( x ) => ( { ...x , type : DefinitionType . mutation } ) as any ,
350
350
} )
351
351
352
352
for ( const [ endpointName , definition ] of Object . entries (
353
- evaluatedEndpoints
353
+ evaluatedEndpoints ,
354
354
) ) {
355
355
if (
356
356
! inject . overrideExisting &&
@@ -361,7 +361,7 @@ export function buildCreateApi<Modules extends [Module<any>, ...Module<any>[]]>(
361
361
process . env . NODE_ENV === 'development'
362
362
) {
363
363
console . error (
364
- `called \`injectEndpoints\` to override already-existing endpointName ${ endpointName } without specifying \`overrideExisting: true\``
364
+ `called \`injectEndpoints\` to override already-existing endpointName ${ endpointName } without specifying \`overrideExisting: true\`` ,
365
365
)
366
366
}
367
367
0 commit comments