Skip to content

Commit

Permalink
Merge pull request #3 from kculmback-eig/patch-1
Browse files Browse the repository at this point in the history
Generic type `YEvent<T>` requires 1 type argument(s)
  • Loading branch information
sep2 committed Apr 26, 2022
2 parents d727ed8 + 6c427c9 commit 0563f4e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/immer-yjs/src/immer-yjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enablePatches()

export type Snapshot = JSONObject | JSONArray

function applyYEvent<T extends JSONValue>(base: T, event: Y.YEvent) {
function applyYEvent<T extends JSONValue>(base: T, event: Y.YEvent<any>) {
if (event instanceof Y.YMapEvent && isJSONObject(base)) {
const source = event.target as Y.Map<any>

Expand Down Expand Up @@ -46,7 +46,7 @@ function applyYEvent<T extends JSONValue>(base: T, event: Y.YEvent) {
}
}

function applyYEvents<S extends Snapshot>(snapshot: S, events: Y.YEvent[]) {
function applyYEvents<S extends Snapshot>(snapshot: S, events: Y.YEvent<any>[]) {
return produce(snapshot, (target) => {
for (const event of events) {
const base = event.path.reduce((obj, step) => {
Expand Down Expand Up @@ -192,7 +192,7 @@ export function bind<S extends Snapshot>(source: Y.Map<any> | Y.Array<any>, opti
return () => void subscription.delete(fn)
}

const observer = (events: Y.YEvent[]) => {
const observer = (events: Y.YEvent<any>[]) => {
snapshot = applyYEvents(get(), events)
subscription.forEach((fn) => fn(get()))
}
Expand Down

0 comments on commit 0563f4e

Please sign in to comment.