Skip to content

Commit 2fdf7ed

Browse files
committed
Refactor ISendFutureRequestOpts
Make it a union of timeout/action future request types, to make its purpose more clear
1 parent 131446d commit 2fdf7ed

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/@types/requests.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import { EitherAnd } from "matrix-events-sdk/lib/types";
18-
1917
import { IContent, IEvent } from "../models/event";
2018
import { Preset, Visibility } from "./partials";
2119
import { IEventWithRoomId, SearchKey } from "./search";
@@ -86,7 +84,10 @@ export interface IFutureTimeout {
8684
future_timeout: number;
8785
}
8886

89-
export type ISendFutureRequestOpts = EitherAnd<IFutureGroupId, IFutureTimeout>;
87+
export type ISendTimeoutFutureRequestOpts = IFutureTimeout & Partial<IFutureGroupId>;
88+
export type ISendActionFutureRequestOpts = IFutureGroupId;
89+
90+
export type ISendFutureRequestOpts = ISendTimeoutFutureRequestOpts | ISendActionFutureRequestOpts;
9091

9192
export interface IFutureTokens {
9293
send_token: string;
@@ -100,7 +101,7 @@ export interface ITimeoutFutureTokens extends IFutureTokens {
100101
export type ISendActionFutureResponse = IFutureGroupId & IFutureTokens;
101102
export type ISendTimeoutFutureResponse = IFutureGroupId & ITimeoutFutureTokens;
102103

103-
export type ISendFutureResponse<F extends ISendFutureRequestOpts> = F extends IFutureTimeout
104+
export type ISendFutureResponse<F extends ISendFutureRequestOpts> = F extends ISendTimeoutFutureRequestOpts
104105
? ISendTimeoutFutureResponse
105106
: ISendActionFutureResponse;
106107

0 commit comments

Comments
 (0)