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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
//// [unionTypeCallSignatures6.ts]
type A = { a: string };
type B = { b: number };
type C = { c: string };
type D = { d: number };
type F0 = () => void;
// #31547
type F1 = (this: A) => void;
type F2 = (this: B) => void;
declare var f1: F1 | F2;
f1(); // error
declare var f2: F0 | F1;
f2(); // error
interface F3 {
(this: A): void;
(this: B): void;
}
interface F4 {
(this: C): void;
(this: D): void;
}
interface F5 {
(this: C): void;
(this: B): void;
}
declare var x1: A & C & {
f0: F0 | F3;
f1: F1 | F3;
f2: F1 | F4;
f3: F3 | F4;
f4: F3 | F5;
}
x1.f0();
x1.f1();
x1.f2();
x1.f3(); // error
x1.f4(); // error
declare var x2: A & B & {
f4: F3 | F5;
}
x2.f4();
type F6 = (this: A & B) => void;
declare var f3: F1 | F6;
f3(); // error
interface F7 {
(this: A & B & C): void;
(this: A & B): void;
}
declare var f4: F6 | F7;
f4(); // error
//// [unionTypeCallSignatures6.js]
f1(); // error
f2(); // error
x1.f0();
x1.f1();
x1.f2();
x1.f3(); // error
x1.f4(); // error
x2.f4();
f3(); // error
f4(); // error
|