Skip to content

Commit

Permalink
Cleanup call to createPatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
waynesbrain committed Oct 5, 2024
1 parent d1a4f4c commit abbfd65
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/core/src/FileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,13 @@ export class FileSystem<FT extends FileTypes<FT>> extends FileTree {
origData = (await this.get(toEntry)).data as D;
}
if (typeof writerOrData === "function") {
const writer = writerOrData;
const [data, patches, undo] = await createPatch(
origData,
writer as (data: unknown) => D | Promise<D> | void | Promise<void>,
);
// We don't need mutative's Draft<D> here to remove readonly from D's
// properties since D represents a mutable type already.
const writer = writerOrData as (
// data: Draft<T> is default, but for local cast skip the type import.
data: unknown,
) => D | Promise<D> | void | Promise<void>;
const [data, patches, undo] = await createPatch(origData, writer);
if (patches.length < 1) {
// No change.
return toEntry;
Expand Down

0 comments on commit abbfd65

Please sign in to comment.