-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
remove any
where applicable
#377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,13 @@ export interface DictionaryNum<T> { | |
|
||
/** | ||
* @alpha | ||
* why was this a class, not an interface? | ||
*/ | ||
export abstract class Dictionary<T> implements DictionaryNum<T> { | ||
[id: string]: T | undefined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, this definition came straight from I think the intent here is more that the user-level code understands that So, yeah, the internal casts are a bit weird, but it seems like an okay tradeoff to get the right behavior at the user level? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. That's the lifelong discussion in the TS issues if an index signature should actually be undefined per default and it comes down to "if you really want to signal this, add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And yeah, I never understood why this was an |
||
// 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 | ||
} | ||
|
||
/** | ||
|
@@ -39,11 +43,6 @@ export type Update<T> = { id: EntityId; changes: Partial<T> } | |
*/ | ||
export type EntityMap<T> = (entity: T) => T | ||
|
||
/** | ||
* @alpha | ||
*/ | ||
export type TypeOrPayloadAction<T> = T | PayloadAction<T> | ||
|
||
/** | ||
* @alpha | ||
*/ | ||
|
@@ -58,71 +57,48 @@ export interface EntityDefinition<T> { | |
} | ||
|
||
export interface EntityStateAdapter<T> { | ||
addOne<S extends EntityState<T>>(state: S, entity: TypeOrPayloadAction<T>): S | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the net benefit of dropping There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You had the function overload only taking the PayloadAction there anyways, so it's either remove that or cut this back to prevent duplication. Since I remembered you mentioned that you had some problem with this |
||
addOne<S extends EntityState<T>>(state: S, entity: T): S | ||
addOne<S extends EntityState<T>>(state: S, action: PayloadAction<T>): S | ||
|
||
addMany<S extends EntityState<T>>( | ||
state: S, | ||
entities: TypeOrPayloadAction<T[]> | ||
): S | ||
addMany<S extends EntityState<T>>(state: S, entities: T[]): S | ||
addMany<S extends EntityState<T>>(state: S, entities: PayloadAction<T[]>): S | ||
|
||
setAll<S extends EntityState<T>>( | ||
state: S, | ||
entities: TypeOrPayloadAction<T[]> | ||
): S | ||
setAll<S extends EntityState<T>>(state: S, entities: T[]): S | ||
setAll<S extends EntityState<T>>(state: S, entities: PayloadAction<T[]>): S | ||
|
||
removeOne<S extends EntityState<T>>( | ||
state: S, | ||
key: TypeOrPayloadAction<EntityId> | ||
): S | ||
removeOne<S extends EntityState<T>>(state: S, key: EntityId): S | ||
removeOne<S extends EntityState<T>>(state: S, key: PayloadAction<EntityId>): S | ||
|
||
removeMany<S extends EntityState<T>>(state: S, keys: EntityId[]): S | ||
removeMany<S extends EntityState<T>>( | ||
state: S, | ||
keys: TypeOrPayloadAction<EntityId[]> | ||
keys: PayloadAction<EntityId[]> | ||
): S | ||
|
||
removeAll<S extends EntityState<T>>(state: S): S | ||
|
||
updateOne<S extends EntityState<T>>( | ||
state: S, | ||
update: TypeOrPayloadAction<Update<T>> | ||
): S | ||
updateOne<S extends EntityState<T>>(state: S, update: Update<T>): S | ||
updateOne<S extends EntityState<T>>( | ||
state: S, | ||
update: PayloadAction<Update<T>> | ||
): S | ||
|
||
updateMany<S extends EntityState<T>>( | ||
state: S, | ||
updates: TypeOrPayloadAction<Update<T>[]> | ||
): S | ||
updateMany<S extends EntityState<T>>(state: S, updates: Update<T>[]): S | ||
updateMany<S extends EntityState<T>>( | ||
state: S, | ||
updates: PayloadAction<Update<T>[]> | ||
): S | ||
|
||
upsertOne<S extends EntityState<T>>( | ||
state: S, | ||
entity: TypeOrPayloadAction<T> | ||
): S | ||
upsertOne<S extends EntityState<T>>(state: S, entity: T): S | ||
upsertOne<S extends EntityState<T>>(state: S, entity: PayloadAction<T>): S | ||
|
||
upsertMany<S extends EntityState<T>>( | ||
state: S, | ||
entities: TypeOrPayloadAction<T[]> | ||
): S | ||
upsertMany<S extends EntityState<T>>(state: S, entities: T[]): S | ||
upsertMany<S extends EntityState<T>>( | ||
state: S, | ||
entities: PayloadAction<T[]> | ||
): S | ||
|
||
map<S extends EntityState<T>>( | ||
state: S, | ||
map: TypeOrPayloadAction<EntityMap<T>> | ||
): S | ||
map<S extends EntityState<T>>(state: S, map: EntityMap<T>): S | ||
map<S extends EntityState<T>>(state: S, map: PayloadAction<EntityMap<T>>): S | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.