Skip to content

Commit

Permalink
Fix topic types (#4678)
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot authored Feb 3, 2025
1 parent 5be104a commit 624b8a2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/@types/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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<MTopicEvent>;

0 comments on commit 624b8a2

Please sign in to comment.