TypeScript/tests/baselines/reference/unionTypeCallSignatures6.types
Nathan Shively-Sanders 71c1da020f
redo #28564 (#36665)
2020-02-07 09:55:29 -08:00

151 lines
2.4 KiB
Plaintext

=== tests/cases/conformance/types/union/unionTypeCallSignatures6.ts ===
type A = { a: string };
>A : A
>a : string
type B = { b: number };
>B : B
>b : number
type C = { c: string };
>C : C
>c : string
type D = { d: number };
>D : D
>d : number
type F0 = () => void;
>F0 : F0
// #31547
type F1 = (this: A) => void;
>F1 : F1
>this : A
type F2 = (this: B) => void;
>F2 : F2
>this : B
declare var f1: F1 | F2;
>f1 : F1 | F2
f1(); // error
>f1() : void
>f1 : F1 | F2
declare var f2: F0 | F1;
>f2 : F1 | F0
f2(); // error
>f2() : void
>f2 : F1 | F0
interface F3 {
(this: A): void;
>this : A
(this: B): void;
>this : B
}
interface F4 {
(this: C): void;
>this : C
(this: D): void;
>this : D
}
interface F5 {
(this: C): void;
>this : C
(this: B): void;
>this : B
}
declare var x1: A & C & {
>x1 : A & C & { f0: F0 | F3; f1: F1 | F3; f2: F1 | F4; f3: F3 | F4; f4: F3 | F5; }
f0: F0 | F3;
>f0 : F0 | F3
f1: F1 | F3;
>f1 : F1 | F3
f2: F1 | F4;
>f2 : F1 | F4
f3: F3 | F4;
>f3 : F3 | F4
f4: F3 | F5;
>f4 : F3 | F5
}
x1.f0();
>x1.f0() : void
>x1.f0 : F0 | F3
>x1 : A & C & { f0: F0 | F3; f1: F1 | F3; f2: F1 | F4; f3: F3 | F4; f4: F3 | F5; }
>f0 : F0 | F3
x1.f1();
>x1.f1() : void
>x1.f1 : F1 | F3
>x1 : A & C & { f0: F0 | F3; f1: F1 | F3; f2: F1 | F4; f3: F3 | F4; f4: F3 | F5; }
>f1 : F1 | F3
x1.f2();
>x1.f2() : void
>x1.f2 : F1 | F4
>x1 : A & C & { f0: F0 | F3; f1: F1 | F3; f2: F1 | F4; f3: F3 | F4; f4: F3 | F5; }
>f2 : F1 | F4
x1.f3(); // error
>x1.f3() : any
>x1.f3 : F3 | F4
>x1 : A & C & { f0: F0 | F3; f1: F1 | F3; f2: F1 | F4; f3: F3 | F4; f4: F3 | F5; }
>f3 : F3 | F4
x1.f4(); // error
>x1.f4() : void
>x1.f4 : F3 | F5
>x1 : A & C & { f0: F0 | F3; f1: F1 | F3; f2: F1 | F4; f3: F3 | F4; f4: F3 | F5; }
>f4 : F3 | F5
declare var x2: A & B & {
>x2 : A & B & { f4: F3 | F5; }
f4: F3 | F5;
>f4 : F3 | F5
}
x2.f4();
>x2.f4() : void
>x2.f4 : F3 | F5
>x2 : A & B & { f4: F3 | F5; }
>f4 : F3 | F5
type F6 = (this: A & B) => void;
>F6 : F6
>this : A & B
declare var f3: F1 | F6;
>f3 : F1 | F6
f3(); // error
>f3() : void
>f3 : F1 | F6
interface F7 {
(this: A & B & C): void;
>this : A & B & C
(this: A & B): void;
>this : A & B
}
declare var f4: F6 | F7;
>f4 : F6 | F7
f4(); // error
>f4() : void
>f4 : F6 | F7