From 05b56c70573ee69678e1da5c985b37176ccd55d2 Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Tue, 5 Nov 2024 15:24:16 +0000 Subject: [PATCH] Add type def for custom reaction type. --- src/@types/matrix-js-sdk.d.ts | 18 ++++++++++++++++++ src/button/ReactionToggleButton.tsx | 5 ++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 src/@types/matrix-js-sdk.d.ts diff --git a/src/@types/matrix-js-sdk.d.ts b/src/@types/matrix-js-sdk.d.ts new file mode 100644 index 00000000..dc27b1ef --- /dev/null +++ b/src/@types/matrix-js-sdk.d.ts @@ -0,0 +1,18 @@ +/* +Copyright 2024 New Vector Ltd. + +SPDX-License-Identifier: AGPL-3.0-only +Please see LICENSE in the repository root for full details. +*/ + +import { + ElementCallReactionEventType, + ECallReactionEventContent, +} from "../reactions"; + +// Extend Matrix JS SDK types via Typescript declaration merging to support unspecced event fields and types +declare module "matrix-js-sdk/src/types" { + export interface TimelineEvents { + [ElementCallReactionEventType]: ECallReactionEventContent; + } +} diff --git a/src/button/ReactionToggleButton.tsx b/src/button/ReactionToggleButton.tsx index e5ffb973..f21a88d4 100644 --- a/src/button/ReactionToggleButton.tsx +++ b/src/button/ReactionToggleButton.tsx @@ -36,7 +36,6 @@ import { useReactions } from "../useReactions"; import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships"; import styles from "./ReactionToggleButton.module.css"; import { - ECallReactionEventContent, ReactionOption, ReactionSet, ElementCallReactionEventType, @@ -195,7 +194,6 @@ export function ReactionToggleButton({ const parentEventId = myMembership.eventId; try { setBusy(true); - // @ts-expect-error Trying to send a unspec'd event seems to miss the 3rd overload, need to come back to this. await client.sendEvent( rtcSession.room.roomId, null, @@ -207,7 +205,8 @@ export function ReactionToggleButton({ }, emoji: reaction.emoji, name: reaction.name, - } as ECallReactionEventContent, + }, + undefined, ); // Do NOT close the menu after this. } catch (ex) {