Skip to content

Commit e109348

Browse files
author
Lenz Weber
committed
re-add | undefined, remove review comments
1 parent 65d66dc commit e109348

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

etc/redux-toolkit.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export interface CreateSliceOptions<State = any, CR extends SliceCaseReducers<St
159159
}
160160

161161
// @alpha (undocumented)
162-
export abstract class Dictionary<T> implements DictionaryNum<T> {
162+
export interface Dictionary<T> extends DictionaryNum<T> {
163163
// (undocumented)
164164
[id: string]: T | undefined;
165165
}

src/createAction.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,6 @@ export function createAction(type: string, prepareAction?: Function): any {
296296
return actionCreator
297297
}
298298

299-
/**
300-
* The previous typings implied some assertion for the types of Payload/Error/Meta, which was just not the case.
301-
* I'd suggest we just do something like this - assert the shape of a FSA, but make no assumptions about the contents.
302-
*/
303299
export function isFSA(
304300
action: unknown
305301
): action is {

src/entities/models.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@ export interface DictionaryNum<T> {
2424

2525
/**
2626
* @alpha
27-
* why was this a class, not an interface?
2827
*/
29-
export abstract class Dictionary<T> implements DictionaryNum<T> {
30-
// I get why you're adding "undefined" here, but there is not one check for it actually not being undefined down the line
31-
// on the contrary, some casts to `any` were necessary because `Object.entities(dictionary).sort()` were not possible any more
32-
// due to the `sort` assuming parameters of T.
33-
[id: string]: T
28+
export interface Dictionary<T> extends DictionaryNum<T> {
29+
[id: string]: T | undefined
3430
}
3531

3632
/**

src/entities/sorted_state_adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function createSortedStateAdapter<T>(
130130
state.entities[selectId(model)] = model
131131
})
132132

133-
const allEntities = Object.values(state.entities)
133+
const allEntities = Object.values(state.entities) as T[]
134134
allEntities.sort(sort)
135135

136136
const newSortedIds = allEntities.map(selectId)

0 commit comments

Comments
 (0)