type Source = { (type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; } interface Action1 { (arg: T): void; } interface MessageEventLike { source: WindowLike; origin: string; data: T; } interface PostMessageObject { postMessage(message: T, host: string): void; } interface WindowLike extends PostMessageObject { addEventListener(type: "message", handler: Action1>): void; addEventListener(type: string, handler: Action1): void; removeEventListener(type: "message", handler: Action1>): void; removeEventListener(type: string, handler: Action1): void; } type Target = { (type: "message", handler: Action1>): void; (type: string, handler: Action1): void; }; function f1(s: Source, t: Target) { t = s; }