Skip to content

Commit

Permalink
Add unwrapWritableDraft util
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Feb 22, 2024
1 parent fa50c9f commit 63c0cb3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/utils/unwrapWritableDraft.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type * as immerTypesExternal from "immer/dist/types/types-external";

export type { immerTypesExternal };

export type UnwrapWritableDraft<T> = T extends immerTypesExternal.WritableDraft<infer U> ? U : never;

export function unwrapWritableDraft<T extends immerTypesExternal.WritableDraft<any>>(
wrapped: T
): UnwrapWritableDraft<T> {
return wrapped as any;
}

0 comments on commit 63c0cb3

Please sign in to comment.