@@ -24,6 +24,10 @@ import {
2424 ISendEventToWidgetActionRequest ,
2525 ISendToDeviceToWidgetActionRequest ,
2626 ISendEventFromWidgetResponseData ,
27+ IWidgetApiRequestData ,
28+ WidgetApiAction ,
29+ IWidgetApiResponse ,
30+ IWidgetApiResponseData ,
2731} from "matrix-widget-api" ;
2832
2933import { MatrixEvent , IEvent , IContent , EventStatus } from "./models/event.ts" ;
@@ -150,20 +154,24 @@ export class RoomWidgetClient extends MatrixClient {
150154 super ( opts ) ;
151155
152156 const transportSend = this . widgetApi . transport . send . bind ( this . widgetApi . transport ) ;
153- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
154- this . widgetApi . transport . send = async ( action , data ) => {
157+ this . widgetApi . transport . send = async < T extends IWidgetApiRequestData , R extends IWidgetApiResponseData = IWidgetApiAcknowledgeResponseData > (
158+ action : WidgetApiAction ,
159+ data : T ,
160+ ) : Promise < R > => {
155161 try {
156- return await transportSend ( action , data ) ;
162+ return await transportSend < T , R > ( action , data ) ;
157163 } catch ( error ) {
158164 processAndThrow ( error ) ;
159165 }
160166 } ;
161167
162168 const transportSendComplete = this . widgetApi . transport . sendComplete . bind ( this . widgetApi . transport ) ;
163- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
164- this . widgetApi . transport . sendComplete = async ( action , data ) => {
169+ this . widgetApi . transport . sendComplete = async < T extends IWidgetApiRequestData , R extends IWidgetApiResponse > (
170+ action : WidgetApiAction ,
171+ data : T ,
172+ ) : Promise < R > => {
165173 try {
166- return await transportSendComplete ( action , data ) ;
174+ return await transportSendComplete < T , R > ( action , data ) ;
167175 } catch ( error ) {
168176 processAndThrow ( error ) ;
169177 }
0 commit comments