Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor type should be based on T not Draft<Immutable<T>> #214

Open
cefn opened this issue Feb 26, 2023 · 0 comments
Open

Editor type should be based on T not Draft<Immutable<T>> #214

cefn opened this issue Feb 26, 2023 · 0 comments

Comments

@cefn
Copy link
Owner

cefn commented Feb 26, 2023

For some reason the definition of Editor as consuming a Draft<Immutable<T>>, (where Draft from Immer was intended to undo the Immutable mapping), leads to problems for indexed object structures.

An example error reads like...

Type 'Evidenced' cannot be used to index type 'Draft<{ [k in Evidenced]: boolean; }>

Changing the definition of Editor like this...

// BEFORE
export declare type Editor<T> = (draft: Draft<T>) => void;
// AFTER
export declare type Editor<T> = (draft: T) => void;

...should address some issues.

Incidentally this remnant from the use of Immer's castDraft is still in the documentation, which is a mistake.

 * @param castDraft Unsafely casts `Immutable` references to mutable to use them
 * in the next draft.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant