From 624b8a242e01d685eb92101b0b630243c5134686 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Mon, 3 Feb 2025 09:03:58 +0000 Subject: [PATCH] Fix topic types (#4678) --- src/@types/topic.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/@types/topic.ts b/src/@types/topic.ts index 6254191e8f..b819eb85b5 100644 --- a/src/@types/topic.ts +++ b/src/@types/topic.ts @@ -13,9 +13,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ - -import { EitherAnd } from "matrix-events-sdk"; - import { UnstableValue } from "../NamespacedValue.ts"; import { IMessageRendering } from "./extensible_events.ts"; @@ -52,12 +49,17 @@ export const M_TOPIC = new UnstableValue("m.topic", "org.matrix.msc3765.topic"); */ export type MTopicContent = IMessageRendering[]; +type MTopicStable = { [M_TOPIC.altName]: MTopicContent }; +type MTopicUnstable = { [M_TOPIC.name]: MTopicContent }; + /** * The event definition for an m.topic event (in content) */ -export type MTopicEvent = EitherAnd<{ [M_TOPIC.name]: MTopicContent }, { [M_TOPIC.altName]: MTopicContent }>; +export type MTopicEvent = (MTopicStable & MTopicUnstable) | MTopicStable | MTopicUnstable; /** * The event content for an m.room.topic event */ -export type MRoomTopicEventContent = { topic: string | null | undefined } & (MTopicEvent | {}); +export type MRoomTopicEventContent = { + topic: string | null | undefined; +} & Partial;