Skip to content

Commit 98b93e3

Browse files
committed
Fix @typescript-eslint/consistent-indexed-object-style related issues
1 parent 88f5998 commit 98b93e3

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

packages/toolkit/src/combineSlices.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ type SliceLikeReducerPath<A extends AnySliceLike> =
2323
type SliceLikeState<A extends AnySliceLike> =
2424
A extends SliceLike<any, infer State> ? State : never
2525

26-
export type WithSlice<A extends AnySliceLike> = {
27-
[Path in SliceLikeReducerPath<A>]: SliceLikeState<A>
28-
}
26+
export type WithSlice<A extends AnySliceLike> = Record<
27+
SliceLikeReducerPath<A>,
28+
SliceLikeState<A>
29+
>
2930

3031
type ReducerMap = Record<string, Reducer>
3132

packages/toolkit/src/createSlice.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export interface Slice<
111111
* Equivalent to `slice.getSelectors((state: RootState) => state[slice.reducerPath])`.
112112
*/
113113
get selectors(): Id<
114-
SliceDefinedSelectors<State, Selectors, { [K in ReducerPath]: State }>
114+
SliceDefinedSelectors<State, Selectors, Record<ReducerPath, State>>
115115
>
116116

117117
/**
@@ -133,7 +133,7 @@ export interface Slice<
133133
*
134134
* Will throw an error if slice is not found.
135135
*/
136-
selectSlice(state: { [K in ReducerPath]: State }): State
136+
selectSlice(state: Record<ReducerPath, State>): State
137137
}
138138

139139
/**
@@ -172,7 +172,7 @@ type InjectedSlice<
172172
SliceDefinedSelectors<
173173
State,
174174
Selectors,
175-
{ [K in ReducerPath]?: State | undefined }
175+
Partial<Record<ReducerPath, State | undefined>>
176176
>
177177
>
178178

@@ -181,7 +181,7 @@ type InjectedSlice<
181181
*
182182
* Returns initial state if slice is not found.
183183
*/
184-
selectSlice(state: { [K in ReducerPath]?: State | undefined }): State
184+
selectSlice(state: Partial<Record<ReducerPath, State | undefined>>): State
185185
}
186186

187187
/**
@@ -760,7 +760,7 @@ export function buildCreateSlice({ creators }: BuildCreateSliceConfig = {}) {
760760
Slice<State, CaseReducers, Name, CurrentReducerPath, Selectors>,
761761
'getSelectors' | 'selectors' | 'selectSlice' | 'reducerPath'
762762
> {
763-
function selectSlice(state: { [K in CurrentReducerPath]: State }) {
763+
function selectSlice(state: Record<CurrentReducerPath, State>) {
764764
let sliceState = state[reducerPath]
765765
if (typeof sliceState === 'undefined') {
766766
if (injected) {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,13 @@ export type CombinedState<
241241
config: ConfigState<ReducerPath>
242242
}
243243

244-
export type InvalidationState<TagTypes extends string> = {
245-
[_ in TagTypes]: {
244+
export type InvalidationState<TagTypes extends string> = Record<
245+
TagTypes,
246+
{
246247
[id: string]: QueryCacheKey[]
247248
[id: number]: QueryCacheKey[]
248249
}
249-
}
250+
>
250251

251252
export type QueryState<D extends EndpointDefinitions> = Record<
252253
string,

0 commit comments

Comments
 (0)