From f044912a9e119765b5d9f6b95bfdcba8468741ae Mon Sep 17 00:00:00 2001 From: Arya Emami Date: Mon, 4 Nov 2024 14:52:57 -0600 Subject: [PATCH] Fix `@typescript-eslint/consistent-indexed-object-style` related issues --- packages/toolkit/src/combineSlices.ts | 7 ++++--- packages/toolkit/src/createSlice.ts | 10 +++++----- packages/toolkit/src/query/core/apiState.ts | 7 ++++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/toolkit/src/combineSlices.ts b/packages/toolkit/src/combineSlices.ts index 08d62d5d59..62cdbcb495 100644 --- a/packages/toolkit/src/combineSlices.ts +++ b/packages/toolkit/src/combineSlices.ts @@ -23,9 +23,10 @@ type SliceLikeReducerPath = type SliceLikeState = A extends SliceLike ? State : never -export type WithSlice = { - [Path in SliceLikeReducerPath]: SliceLikeState -} +export type WithSlice = Record< + SliceLikeReducerPath, + SliceLikeState +> type ReducerMap = Record diff --git a/packages/toolkit/src/createSlice.ts b/packages/toolkit/src/createSlice.ts index 6ba1b92608..3662bd688f 100644 --- a/packages/toolkit/src/createSlice.ts +++ b/packages/toolkit/src/createSlice.ts @@ -111,7 +111,7 @@ export interface Slice< * Equivalent to `slice.getSelectors((state: RootState) => state[slice.reducerPath])`. */ get selectors(): Id< - SliceDefinedSelectors + SliceDefinedSelectors> > /** @@ -133,7 +133,7 @@ export interface Slice< * * Will throw an error if slice is not found. */ - selectSlice(state: { [K in ReducerPath]: State }): State + selectSlice(state: Record): State } /** @@ -172,7 +172,7 @@ type InjectedSlice< SliceDefinedSelectors< State, Selectors, - { [K in ReducerPath]?: State | undefined } + Partial> > > @@ -181,7 +181,7 @@ type InjectedSlice< * * Returns initial state if slice is not found. */ - selectSlice(state: { [K in ReducerPath]?: State | undefined }): State + selectSlice(state: Partial>): State } /** @@ -760,7 +760,7 @@ export function buildCreateSlice({ creators }: BuildCreateSliceConfig = {}) { Slice, 'getSelectors' | 'selectors' | 'selectSlice' | 'reducerPath' > { - function selectSlice(state: { [K in CurrentReducerPath]: State }) { + function selectSlice(state: Record) { let sliceState = state[reducerPath] if (typeof sliceState === 'undefined') { if (injected) { diff --git a/packages/toolkit/src/query/core/apiState.ts b/packages/toolkit/src/query/core/apiState.ts index d4ebb1e00c..68166d08b7 100644 --- a/packages/toolkit/src/query/core/apiState.ts +++ b/packages/toolkit/src/query/core/apiState.ts @@ -241,12 +241,13 @@ export type CombinedState< config: ConfigState } -export type InvalidationState = { - [_ in TagTypes]: { +export type InvalidationState = Record< + TagTypes, + { [id: string]: QueryCacheKey[] [id: number]: QueryCacheKey[] } -} +> export type QueryState = Record< string,