@@ -131,12 +131,10 @@ import {
131131 IRelationsResponse ,
132132 IRoomDirectoryOptions ,
133133 ISearchOpts ,
134- ISendActionFutureResponse ,
135134 ISendEventResponse ,
136135 ISendFutureGroupResponse ,
137136 ISendFutureRequestOpts ,
138137 ISendFutureResponse ,
139- ISendTimeoutFutureResponse ,
140138 IStatusResponse ,
141139 ITagsResponse ,
142140 KnockRoomOpts ,
@@ -4653,14 +4651,14 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
46534651 futureOpts : F ,
46544652 txnId ?: string ,
46554653 ) : Promise < ISendFutureResponse < F > > ;
4656- private sendCompleteEvent (
4654+ private sendCompleteEvent < F extends ISendFutureRequestOpts > (
46574655 roomId : string ,
46584656 threadId : string | null ,
46594657 eventObject : Partial < IEvent > ,
4660- futureOptsOrTxnId ?: ISendFutureRequestOpts | string ,
4658+ futureOptsOrTxnId ?: F | string ,
46614659 txnIdOrVoid ?: string ,
4662- ) : Promise < ISendEventResponse | ISendTimeoutFutureResponse | ISendActionFutureResponse > {
4663- let futureOpts : ISendFutureRequestOpts | undefined ;
4660+ ) : Promise < ISendEventResponse | ISendFutureResponse < F > > {
4661+ let futureOpts : F | undefined ;
46644662 let txnId : string | undefined ;
46654663 if ( typeof futureOptsOrTxnId === "string" ) {
46664664 txnId = futureOptsOrTxnId ;
@@ -4743,11 +4741,11 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
47434741 event : MatrixEvent ,
47444742 futureOpts : F ,
47454743 ) : Promise < ISendFutureResponse < F > > ;
4746- protected async encryptAndSendEvent (
4744+ protected async encryptAndSendEvent < F extends ISendFutureRequestOpts > (
47474745 room : Room | null ,
47484746 event : MatrixEvent ,
4749- futureOpts ?: ISendFutureRequestOpts ,
4750- ) : Promise < ISendEventResponse | ISendTimeoutFutureResponse | ISendActionFutureResponse > {
4747+ futureOpts ?: F ,
4748+ ) : Promise < ISendEventResponse | ISendFutureResponse < F > > {
47514749 // TODO: Allow encrypted futures, and encrypt them properly
47524750 if ( futureOpts ) {
47534751 return this . sendEventHttpRequest ( event , futureOpts ) ;
@@ -4908,10 +4906,10 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
49084906 event : MatrixEvent ,
49094907 futureOpts : F ,
49104908 ) : Promise < ISendFutureResponse < F > > ;
4911- private sendEventHttpRequest (
4909+ private sendEventHttpRequest < F extends ISendFutureRequestOpts > (
49124910 event : MatrixEvent ,
4913- futureOpts ?: ISendFutureRequestOpts ,
4914- ) : Promise < ISendEventResponse | ISendTimeoutFutureResponse | ISendActionFutureResponse > {
4911+ futureOpts ?: F ,
4912+ ) : Promise < ISendEventResponse | ISendFutureResponse < F > > {
49154913 let txnId = event . getTxnId ( ) ;
49164914 if ( ! txnId ) {
49174915 txnId = this . makeTxnId ( ) ;
@@ -5309,14 +5307,14 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
53095307 txnId ?: string ,
53105308 ) : Promise < ISendFutureResponse < F > > ;
53115309 // eslint-disable-next-line
5312- public async _unstable_sendFuture (
5310+ public async _unstable_sendFuture < F extends ISendFutureRequestOpts > (
53135311 roomId : string ,
5314- futureOpts : ISendFutureRequestOpts ,
5312+ futureOpts : F ,
53155313 threadIdOrEventType : string | null ,
53165314 eventTypeOrContent : string | IContent ,
53175315 contentOrTxnId ?: IContent | string ,
53185316 txnIdOrVoid ?: string ,
5319- ) : Promise < ISendTimeoutFutureResponse | ISendActionFutureResponse > {
5317+ ) : Promise < ISendFutureResponse < F > > {
53205318 if ( ! ( await this . doesServerSupportUnstableFeature ( UNSTABLE_MSC4140_FUTURES ) ) ) {
53215319 throw Error ( "Server does not support the Futures API" ) ;
53225320 }
0 commit comments