diff --git a/src/core/reactor.ts b/src/core/reactor.ts index f0010c012..9b8b92c11 100644 --- a/src/core/reactor.ts +++ b/src/core/reactor.ts @@ -473,16 +473,25 @@ export abstract class Reactor extends Component { * @param src * @param dst */ + + public connect(src: IOPort, dst: IOPort): void; + public connect( + src: CallerPort, + dst: CalleePort + ): void; public connect( - src: CallerPort | IOPort, - dst: CalleePort | IOPort + ...[src, dst]: + | [IOPort, IOPort] + | [CallerPort, CalleePort] ): void { if (src instanceof CallerPort && dst instanceof CalleePort) { this.reactor._connectCall(src, dst); } else if (src instanceof IOPort && dst instanceof IOPort) { this.reactor._connect(src, dst); } else { - // ERROR + throw Error( + "Logically unreachable code: src and dst type mismatch, Caller(ee) port cannot be connected to IOPort." + ); } } @@ -1840,10 +1849,13 @@ interface UtilityFunctions { } export interface MutationSandbox extends ReactionSandbox { - connect: ( - src: CallerPort | IOPort, - dst: CalleePort | IOPort - ) => void; + connect: { + (src: IOPort, dst: IOPort): void; + ( + src: CallerPort, + dst: CalleePort + ): void; + }; disconnect: (src: IOPort, dst?: IOPort) => void;