You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 immertypeObjectish={[key: string]: unknown}|Array<unknown>|Set<unknown>|Map<unknown,unknown>;enablePatches();exportconstcreateImmerStore=<TextendsObjectish>(obj: T)=>{letstate=obj;constdraftStore={// ...undo(){// if I don't use `T extends Objectish` it throws an errorstate=applyPatches(state,undo.inversePatches);},};// ...};
The text was updated successfully, but these errors were encountered:
On Tue, 25 Apr 2023, 15:48 Milan Jaritz, ***@***.***> wrote:
🚀 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 immertype 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);
},
};
// ...};
—
Reply to this email directly, view it on GitHub
<#1041>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBGU6RIJZB2Q3IR4GGLXC7IZNANCNFSM6AAAAAAXLBEX6E>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
🚀 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 theObjectish
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
The text was updated successfully, but these errors were encountered: