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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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,