Skip to content

Commit 73d219a

Browse files
committed
Fix problems related to the @typescript-eslint/array-type rule
1 parent dbeadb5 commit 73d219a

19 files changed

+54
-62
lines changed

packages/toolkit/src/combineSlices.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export interface CombinedSliceReducer<
293293
}
294294
}
295295

296-
type InitialState<Slices extends Array<AnySliceLike | ReducerMap>> =
296+
type InitialState<Slices extends (AnySliceLike | ReducerMap)[]> =
297297
UnionToIntersection<
298298
Slices[number] extends infer Slice
299299
? Slice extends AnySliceLike
@@ -308,7 +308,7 @@ const isSliceLike = (
308308
'reducerPath' in maybeSliceLike &&
309309
typeof maybeSliceLike.reducerPath === 'string'
310310

311-
const getReducers = (slices: Array<AnySliceLike | ReducerMap>) =>
311+
const getReducers = (slices: (AnySliceLike | ReducerMap)[]) =>
312312
slices.flatMap((sliceOrMap) =>
313313
isSliceLike(sliceOrMap)
314314
? [[sliceOrMap.reducerPath, sliceOrMap.reducer] as const]
@@ -362,7 +362,7 @@ const original = (state: any) => {
362362

363363
const noopReducer: Reducer<Record<string, any>> = (state = {}) => state
364364

365-
export function combineSlices<Slices extends Array<AnySliceLike | ReducerMap>>(
365+
export function combineSlices<Slices extends (AnySliceLike | ReducerMap)[]>(
366366
...slices: Slices
367367
): CombinedSliceReducer<Id<InitialState<Slices>>> {
368368
const reducerMap = Object.fromEntries<Reducer>(getReducers(slices))

packages/toolkit/src/configureStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ export interface ConfigureStoreOptions<
8888
enhancers?: (getDefaultEnhancers: GetDefaultEnhancers<M>) => E
8989
}
9090

91-
export type Middlewares<S> = ReadonlyArray<Middleware<AnyNonNullishValue, S>>
91+
export type Middlewares<S> = readonly Middleware<AnyNonNullishValue, S>[]
9292

93-
type Enhancers = ReadonlyArray<StoreEnhancer>
93+
type Enhancers = readonly StoreEnhancer[]
9494

9595
/**
9696
* A Redux store returned by `configureStore()`. Supports dispatching

packages/toolkit/src/createAsyncThunk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface SerializedError {
6161
code?: string
6262
}
6363

64-
const commonProperties: Array<keyof SerializedError> = [
64+
const commonProperties: (keyof SerializedError)[] = [
6565
'name',
6666
'message',
6767
'stack',

packages/toolkit/src/createReducer.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,9 @@ export type ActionMatcherDescription<S, A extends Action> = {
2121
reducer: CaseReducer<S, NoInfer<A>>
2222
}
2323

24-
export type ReadonlyActionMatcherDescriptionCollection<S> = ReadonlyArray<
25-
ActionMatcherDescription<S, any>
26-
>
24+
export type ReadonlyActionMatcherDescriptionCollection<S> = readonly ActionMatcherDescription<S, any>[]
2725

28-
export type ActionMatcherDescriptionCollection<S> = Array<
29-
ActionMatcherDescription<S, any>
30-
>
26+
export type ActionMatcherDescriptionCollection<S> = ActionMatcherDescription<S, any>[]
3127

3228
/**
3329
* A *case reducer* is a reducer function for a specific action type. Case

packages/toolkit/src/entities/models.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ export interface EntityStateAdapter<T, Id extends EntityId> {
129129

130130
updateMany<S extends DraftableEntityState<T, Id>>(
131131
state: PreventAny<S, T, Id>,
132-
updates: ReadonlyArray<Update<T, Id>>,
132+
updates: readonly Update<T, Id>[],
133133
): S
134134
updateMany<S extends DraftableEntityState<T, Id>>(
135135
state: PreventAny<S, T, Id>,
136-
updates: PayloadAction<ReadonlyArray<Update<T, Id>>>,
136+
updates: PayloadAction<readonly Update<T, Id>[]>,
137137
): S
138138

139139
upsertOne<S extends DraftableEntityState<T, Id>>(

packages/toolkit/src/entities/sorted_state_adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export function createSortedStateAdapter<T, Id extends EntityId>(
113113
}
114114

115115
function updateManyMutably(
116-
updates: ReadonlyArray<Update<T, Id>>,
116+
updates: readonly Update<T, Id>[],
117117
state: R,
118118
): void {
119119
let appliedUpdates = false

packages/toolkit/src/entities/unsorted_state_adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function createUnsortedStateAdapter<T, Id extends EntityId>(
129129
}
130130

131131
function updateManyMutably(
132-
updates: ReadonlyArray<Update<T, Id>>,
132+
updates: readonly Update<T, Id>[],
133133
state: R,
134134
): void {
135135
const newKeys: Record<string, Id> = {}

packages/toolkit/src/query/core/apiState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ export type CombinedState<
243243

244244
export type InvalidationState<TagTypes extends string> = {
245245
[_ in TagTypes]: {
246-
[id: string]: Array<QueryCacheKey>
247-
[id: number]: Array<QueryCacheKey>
246+
[id: string]: QueryCacheKey[]
247+
[id: number]: QueryCacheKey[]
248248
}
249249
}
250250

packages/toolkit/src/query/core/buildSelectors.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ export function buildSelectors<
209209

210210
function selectInvalidatedBy(
211211
state: RootState,
212-
tags: ReadonlyArray<TagDescription<string>>,
213-
): Array<{
212+
tags: readonly TagDescription<string>[],
213+
): {
214214
endpointName: string
215215
originalArgs: any
216216
queryCacheKey: QueryCacheKey
217-
}> {
217+
}[] {
218218
const apiState = state[reducerPath]
219219
const toInvalidate = new Set<QueryCacheKey>()
220220
for (const tag of tags.map(expandTagDescription)) {
@@ -254,7 +254,7 @@ export function buildSelectors<
254254
function selectCachedArgsForQuery<QueryName extends QueryKeys<Definitions>>(
255255
state: RootState,
256256
queryName: QueryName,
257-
): Array<QueryArgFrom<Definitions[QueryName]>> {
257+
): QueryArgFrom<Definitions[QueryName]>[] {
258258
return Object.values(state[reducerPath].queries as QueryState<any>)
259259
.filter(
260260
(

packages/toolkit/src/query/core/module.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export interface ApiModules<
197197
* See https://redux-toolkit.js.org/rtk-query/usage/server-side-rendering for details.
198198
*/
199199
getRunningQueriesThunk(): ThunkWithReturnValue<
200-
Array<QueryActionCreatorResult<any>>
200+
QueryActionCreatorResult<any>[]
201201
>
202202

203203
/**
@@ -209,7 +209,7 @@ export interface ApiModules<
209209
* See https://redux-toolkit.js.org/rtk-query/usage/server-side-rendering for details.
210210
*/
211211
getRunningMutationsThunk(): ThunkWithReturnValue<
212-
Array<MutationActionCreatorResult<any>>
212+
MutationActionCreatorResult<any>[]
213213
>
214214

215215
/**
@@ -347,7 +347,7 @@ export interface ApiModules<
347347
* ```
348348
*/
349349
invalidateTags: ActionCreatorWithPayload<
350-
Array<TagDescription<TagTypes>>,
350+
TagDescription<TagTypes>[],
351351
string
352352
>
353353

@@ -358,12 +358,12 @@ export interface ApiModules<
358358
*/
359359
selectInvalidatedBy: (
360360
state: RootState<Definitions, string, ReducerPath>,
361-
tags: ReadonlyArray<TagDescription<TagTypes>>,
362-
) => Array<{
361+
tags: readonly TagDescription<TagTypes>[],
362+
) => {
363363
endpointName: string
364364
originalArgs: any
365365
queryCacheKey: string
366-
}>
366+
}[]
367367

368368
/**
369369
* A function to select all arguments currently cached for a given endpoint.
@@ -373,7 +373,7 @@ export interface ApiModules<
373373
selectCachedArgsForQuery: <QueryName extends QueryKeys<Definitions>>(
374374
state: RootState<Definitions, string, ReducerPath>,
375375
queryName: QueryName,
376-
) => Array<QueryArgFrom<Definitions[QueryName]>>
376+
) => QueryArgFrom<Definitions[QueryName]>[]
377377
}
378378
/**
379379
* Endpoints based on the input endpoints provided to `createApi`, containing `select` and `action matchers`.

0 commit comments

Comments
 (0)