import { EventSource } from '@/infrastructure/Events/EventSource'; import { IEventSource } from '@/infrastructure/Events/IEventSource'; import { FunctionKeys } from '@/TypeHelpers'; export abstract class StubWithObservableMethodCalls { public readonly callHistory = new Array>(); public get methodCalls(): IEventSource> { return this.notifiableMethodCalls; } private readonly notifiableMethodCalls = new EventSource>(); protected registerMethodCall(name: MethodCall) { this.callHistory.push(name); this.notifiableMethodCalls.notify(name); } } type MethodCall = { [K in FunctionKeys]: { methodName: K; args: T[K] extends (...args: infer A) => unknown ? A : never; } }[FunctionKeys];