File: varianceCallbacksAndIndexedAccesses.js

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (36 lines) | stat: -rw-r--r-- 1,193 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//// [varianceCallbacksAndIndexedAccesses.ts]
type Source = {
    <K extends keyof WindowEventMap>(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
}

interface Action1<T> {
    (arg: T): void;
}
interface MessageEventLike<T> {
    source: WindowLike<T>;
    origin: string;
    data: T;
}
interface PostMessageObject<T> {
    postMessage(message: T, host: string): void;
}
interface WindowLike<T> extends PostMessageObject<T> {
    addEventListener(type: "message", handler: Action1<MessageEventLike<T>>): void;
    addEventListener(type: string, handler: Action1<any>): void;
    removeEventListener(type: "message", handler: Action1<MessageEventLike<T>>): void;
    removeEventListener(type: string, handler: Action1<any>): void;
}
type Target = {
    (type: "message", handler: Action1<MessageEventLike<any>>): void;
    (type: string, handler: Action1<any>): void;
};

function f1(s: Source, t: Target) {
    t = s;
}

//// [varianceCallbacksAndIndexedAccesses.js]
function f1(s, t) {
    t = s;
}