Skip to content

Commit

Permalink
Fix @typescript-eslint/consistent-indexed-object-style related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaemami59 committed Dec 3, 2024
1 parent 6f96d8f commit f044912
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
7 changes: 4 additions & 3 deletions packages/toolkit/src/combineSlices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ type SliceLikeReducerPath<A extends AnySliceLike> =
type SliceLikeState<A extends AnySliceLike> =
A extends SliceLike<any, infer State> ? State : never

export type WithSlice<A extends AnySliceLike> = {
[Path in SliceLikeReducerPath<A>]: SliceLikeState<A>
}
export type WithSlice<A extends AnySliceLike> = Record<
SliceLikeReducerPath<A>,
SliceLikeState<A>
>

type ReducerMap = Record<string, Reducer>

Expand Down
10 changes: 5 additions & 5 deletions packages/toolkit/src/createSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export interface Slice<
* Equivalent to `slice.getSelectors((state: RootState) => state[slice.reducerPath])`.
*/
get selectors(): Id<
SliceDefinedSelectors<State, Selectors, { [K in ReducerPath]: State }>
SliceDefinedSelectors<State, Selectors, Record<ReducerPath, State>>
>

/**
Expand All @@ -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<ReducerPath, State>): State
}

/**
Expand Down Expand Up @@ -172,7 +172,7 @@ type InjectedSlice<
SliceDefinedSelectors<
State,
Selectors,
{ [K in ReducerPath]?: State | undefined }
Partial<Record<ReducerPath, State | undefined>>
>
>

Expand All @@ -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<Record<ReducerPath, State | undefined>>): State
}

/**
Expand Down Expand Up @@ -760,7 +760,7 @@ export function buildCreateSlice({ creators }: BuildCreateSliceConfig = {}) {
Slice<State, CaseReducers, Name, CurrentReducerPath, Selectors>,
'getSelectors' | 'selectors' | 'selectSlice' | 'reducerPath'
> {
function selectSlice(state: { [K in CurrentReducerPath]: State }) {
function selectSlice(state: Record<CurrentReducerPath, State>) {
let sliceState = state[reducerPath]
if (typeof sliceState === 'undefined') {
if (injected) {
Expand Down
7 changes: 4 additions & 3 deletions packages/toolkit/src/query/core/apiState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,13 @@ export type CombinedState<
config: ConfigState<ReducerPath>
}

export type InvalidationState<TagTypes extends string> = {
[_ in TagTypes]: {
export type InvalidationState<TagTypes extends string> = Record<
TagTypes,
{
[id: string]: QueryCacheKey[]
[id: number]: QueryCacheKey[]
}
}
>

export type QueryState<D extends EndpointDefinitions> = Record<
string,
Expand Down

0 comments on commit f044912

Please sign in to comment.