Skip to content

Commit

Permalink
type getCurrent to remove Draft type
Browse files Browse the repository at this point in the history
  • Loading branch information
EskiMojo14 committed Jun 28, 2024
1 parent f0088d3 commit d114f81
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/toolkit/src/entities/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { current, isDraft } from 'immer'
import { Draft, current, isDraft } from 'immer'
import type {
IdSelector,
Update,
Expand Down Expand Up @@ -36,8 +36,8 @@ export function ensureEntitiesArray<T, Id extends EntityId>(
return entities
}

export function getCurrent<T>(value: T): T {
return isDraft(value) ? current(value) : value
export function getCurrent<T>(value: T | Draft<T>): T {
return (isDraft(value) ? current(value) : value) as T
}

export function splitAddedUpdatedEntities<T, Id extends EntityId>(
Expand All @@ -47,7 +47,7 @@ export function splitAddedUpdatedEntities<T, Id extends EntityId>(
): [T[], Update<T, Id>[], Id[]] {
newEntities = ensureEntitiesArray(newEntities)

const existingIdsArray = getCurrent(state.ids) as Id[]
const existingIdsArray = getCurrent(state.ids)
const existingIds = new Set<Id>(existingIdsArray)

const added: T[] = []
Expand Down

0 comments on commit d114f81

Please sign in to comment.