Repository: reduxjs/redux-toolkit
Pull request #946 (2021-03-28 03:14:53)

Simplify types


Patch:
diff --git a/src/entities/create_adapter.ts b/src/entities/create_adapter.ts
index b438fa60..1e4b2537 100644
--- a/src/entities/create_adapter.ts
+++ b/src/entities/create_adapter.ts
@@ -1,7 +1,6 @@
 import {
   EntityDefinition,
   Comparer,
-  IdSelector,
   EntityAdapter,
   IndexComparers
 } from './models'
@@ -16,11 +15,11 @@ import { createUnsortedStateAdapter } from './unsorted_state_adapter'
  *
  * @public
  */
-export function createEntityAdapter<
-  T,
-  IC extends IndexComparers<T> = IndexComparers<unknown>
->(options?: EntityDefinition<T, IC>): EntityAdapter<T> {
-  const { selectId, sortComparer, indices = {} as IC } = {
+
+export function createEntityAdapter<T>(
+  options?: EntityDefinition<T>
+): EntityAdapter<T> {
+  const { selectId, sortComparer, indices = {} as IndexComparers<T> } = {
     sortComparer: false as const,
     selectId: (instance: any) => instance.id,
     ...options
diff --git a/src/entities/entity_state.ts b/src/entities/entity_state.ts
index da7b4c41..99ac8e9a 100644
--- a/src/entities/entity_state.ts
+++ b/src/entities/entity_state.ts
@@ -1,8 +1,8 @@
-import { EntityState, IndexComparers, BasicObject, Indices } from './models'
+import { EntityState, IndexComparers, Indices } from './models'
 
 export function getInitialEntityState<V, IC extends IndexComparers<V>>(
   indexComparers: IC
-): EntityState<V, IC> {
+): EntityState<V> {
   const indices = {} as Indices<V, IC>
 
   for (let key in indexComparers) {
diff --git a/src/entities/models.ts b/src/entities/models.ts
index 6f10e9c8..8af7994f 100644
--- a/src/entities/models.ts
+++ b/src/entities/models.ts
@@ -45,13 +45,10 @@ export type Indices<T, IC extends IndexComparers<T>> = {
 /**
  * @public
  */
-export interface EntityState<
-  T,
-  IC extends IndexComparers<T> = IndexComparers<unknown>
-> {
+export interface EntityState<T> {
   ids: EntityId[]
   entities: Dictionary<T>
-  indices: Indices<T, IC>
+  indices: Indices<T, IndexComparers<T>>
 }
 
 export type IndexComparers<T> = {
@@ -61,10 +58,10 @@ export type IndexComparers<T> = {
 /**
  * @public
  */
-export interface EntityDefinition<T, IC extends IndexComparers<T>> {
+export interface EntityDefinition<T> {
   selectId?: IdSelector<T>
   sortComparer?: false | Comparer<T>
-  indices?: IC
+  indices?: IndexComparers<T>
 }
 
 export type PreventAny<S, T> = IsAny<S, EntityState<T>, S>
diff --git a/src/entities/utils.ts b/src/entities/utils.ts
index dd63f7c7..b605631d 100644
--- a/src/entities/utils.ts
+++ b/src/entities/utils.ts
@@ -1,10 +1,4 @@
-import {
-  EntityState,
-  EntityStateAdapter,
-  IdSelector,
-  Update,
-  EntityId
-} from './models'
+import { EntityState, IdSelector, Update, EntityId } from './models'
 
 export function selectIdValue<T>(entity: T, selectId: IdSelector<T>) {
   const key = selectId(entity)


Test patch:
diff --git a/src/entities/indexers.test.ts b/src/entities/indexers.test.ts
index 8c141155..f25539f8 100644
--- a/src/entities/indexers.test.ts
+++ b/src/entities/indexers.test.ts
@@ -31,7 +31,7 @@ indexer.addGroupedIndex(
   attributeKeyer<Cup>('size'),
   'byColorAndSize',
   attributeKeyer<Cup>('color'),
-  (iter, reverseIter) => {
+  (_iter, reverseIter) => {
     return reverseIter()
   }
 )