-
-
Notifications
You must be signed in to change notification settings - Fork 861
Closed
Labels
Description
🚀 Feature Proposal
I created a wrapper for immer in Svelte to enhance its capabilities and I am using a generic type for that. The problem is that applyPatches
accepts a type that extends the Objectish
type which I cannot import. I propose to export this type.
Can this be solved in user-land code?
I can copy paste the type from the source code.
Example
import { applyPatches, enablePatches } from "immer";
// I need to duplicate this because there is no export in immer
type Objectish = { [key: string]: unknown } | Array<unknown> | Set<unknown> | Map<unknown, unknown>;
enablePatches();
export const createImmerStore = <T extends Objectish>(obj: T) => {
let state = obj;
const draftStore = {
// ...
undo() {
// if I don't use `T extends Objectish` it throws an error
state = applyPatches(state, undo.inversePatches);
},
};
// ...
};