From 6c2bcffe6837ce930027801d20a6c191152c4a07 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Mon, 6 Jul 2020 15:36:38 -0600 Subject: [PATCH] update(simperium): add missing optional parameters to event listener (#45814) When creating the original types there was an oversight in the event types for the `Channel` and its `update` event. In some cases the event fires only with the first two parameters: the entity id and data. In the normative case however there are additional parameters available indicating meta information about the update. Those optional paramters have been added here. Although it looks like all three of the last parameters are optional it's actually the case that either you get only the first two or all five. It would not occur that you only get three or four of them but I wasn't sure how to type this beyond function overloads and I believe that it's not the best idea to use function overloads for optional parameters. --- types/simperium/index.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/types/simperium/index.d.ts b/types/simperium/index.d.ts index 7518788cb4..ae00f8b545 100644 --- a/types/simperium/index.d.ts +++ b/types/simperium/index.d.ts @@ -179,7 +179,13 @@ interface ChannelEvent extends SimperiumEvent { indexingStateChange: (isIndexing: boolean) => void; ready: () => void; send: (message: string) => void; - update: (entityId: EntityId, updatedEntity: T) => void; + update: ( + entityId: EntityId, + updatedEntity: T, + originalEntity?: T, + patch?: JSONDiff, + isIndexing?: boolean, + ) => void; version: (entityId: EntityId, version: number, entity: T) => void; }