1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-30 02:21:17 +03:00

Improve types for sendEvent (#12335)

This commit is contained in:
Michael Telatynski
2024-03-25 12:48:48 +00:00
committed by GitHub
parent 4941327c78
commit ef2bd7ae04
26 changed files with 209 additions and 99 deletions

View File

@ -32,7 +32,9 @@ import type {
UploadOpts,
Upload,
StateEvents,
TimelineEvents,
} from "matrix-js-sdk/src/matrix";
import type { RoomMessageEventContent } from "matrix-js-sdk/src/types";
import { Credentials } from "../plugins/homeserver";
export class Client {
@ -98,7 +100,12 @@ export class Client {
const client = await this.prepareClient();
return client.evaluate(
async (client, { roomId, threadId, eventType, content }) => {
return client.sendEvent(roomId, threadId, eventType, content);
return client.sendEvent(
roomId,
threadId,
eventType as keyof TimelineEvents,
content as TimelineEvents[keyof TimelineEvents],
);
},
{ roomId, threadId, eventType, content },
);
@ -125,7 +132,7 @@ export class Client {
const client = await this.prepareClient();
return client.evaluate(
(client, { roomId, content, threadId }) => {
return client.sendMessage(roomId, threadId, content);
return client.sendMessage(roomId, threadId, content as RoomMessageEventContent);
},
{
roomId,