Skip to content

Commit 5ff645c

Browse files
committed
fix(ts): Immer class options and ImmerState types
Minor improvements
1 parent 9c6603e commit 5ff645c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/immer.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,22 @@ export function setUseProxies(useProxies: boolean): void
154154
*/
155155
export function applyPatches<S>(base: S, patches: Patch[]): S
156156

157+
/** Get the underlying object that is represented by the given draft */
157158
export function original<T>(value: T): T | void
158159

160+
/** For detecting an Immer draft */
159161
export function isDraft(value: any): boolean
160162

161163
export class Immer {
162164
constructor(config: {
163165
useProxies?: boolean
164166
autoFreeze?: boolean
165-
onAssign?: (state: ImmerState, prop: keyof any, value: any) => void
166-
onDelete?: (state: ImmerState, prop: keyof any) => void
167+
onAssign?: (
168+
state: ImmerState,
169+
prop: string | number,
170+
value: unknown
171+
) => void
172+
onDelete?: (state: ImmerState, prop: string | number) => void
167173
onCopy?: (state: ImmerState) => void
168174
})
169175
/**
@@ -213,5 +219,5 @@ export interface ImmerState<T = any> {
213219
parent?: ImmerState
214220
base: T
215221
copy: T
216-
assigned: {[prop: string]: boolean}
222+
assigned: {[prop: string]: boolean; [index: number]: boolean}
217223
}

0 commit comments

Comments
 (0)