export `Objectish` type
macmillen opened this issue Β· comments
π 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);
},
};
// ...
};
Feel free to PR
β¦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: ***@***.***>