Skip to content

Commit

Permalink
re-add | undefined, remove review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenz Weber committed Feb 21, 2020
1 parent 65d66dc commit e109348
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion etc/redux-toolkit.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export interface CreateSliceOptions<State = any, CR extends SliceCaseReducers<St
}

// @alpha (undocumented)
export abstract class Dictionary<T> implements DictionaryNum<T> {
export interface Dictionary<T> extends DictionaryNum<T> {
// (undocumented)
[id: string]: T | undefined;
}
Expand Down
4 changes: 0 additions & 4 deletions src/createAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,6 @@ export function createAction(type: string, prepareAction?: Function): any {
return actionCreator
}

/**
* The previous typings implied some assertion for the types of Payload/Error/Meta, which was just not the case.
* I'd suggest we just do something like this - assert the shape of a FSA, but make no assumptions about the contents.
*/
export function isFSA(
action: unknown
): action is {
Expand Down
8 changes: 2 additions & 6 deletions src/entities/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@ export interface DictionaryNum<T> {

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

/**
Expand Down
2 changes: 1 addition & 1 deletion src/entities/sorted_state_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function createSortedStateAdapter<T>(
state.entities[selectId(model)] = model
})

const allEntities = Object.values(state.entities)
const allEntities = Object.values(state.entities) as T[]
allEntities.sort(sort)

const newSortedIds = allEntities.map(selectId)
Expand Down

0 comments on commit e109348

Please sign in to comment.