Skip to content

Commit d114f81

Browse files
committed
type getCurrent to remove Draft type
1 parent f0088d3 commit d114f81

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/toolkit/src/entities/utils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { current, isDraft } from 'immer'
1+
import { Draft, current, isDraft } from 'immer'
22
import type {
33
IdSelector,
44
Update,
@@ -36,8 +36,8 @@ export function ensureEntitiesArray<T, Id extends EntityId>(
3636
return entities
3737
}
3838

39-
export function getCurrent<T>(value: T): T {
40-
return isDraft(value) ? current(value) : value
39+
export function getCurrent<T>(value: T | Draft<T>): T {
40+
return (isDraft(value) ? current(value) : value) as T
4141
}
4242

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

50-
const existingIdsArray = getCurrent(state.ids) as Id[]
50+
const existingIdsArray = getCurrent(state.ids)
5151
const existingIds = new Set<Id>(existingIdsArray)
5252

5353
const added: T[] = []

0 commit comments

Comments
 (0)