cefn / lauf

Monorepo for lauf packages.
MIT License
5 stars 0 forks source link

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

Open cefn opened 1 year ago

cefn commented 1 year ago

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.