File: unionTypeErrorMessageTypeRefs01.types

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 (107 lines) | stat: -rw-r--r-- 1,785 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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
=== tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts ===
interface Foo { foo: any }
>foo : any

interface Bar { bar: any }
>bar : any

interface Baz { baz: any }
>baz : any

interface Kwah { kwah: any }
>kwah : any

////////

interface A<T> {
    aProp: T;
>aProp : T
}

interface B<T> {
    bProp: T;
>bProp : T
}

interface C<T> {
    cProp: T;
>cProp : T
}

declare const a: A<Foo>;
>a : A<Foo>

declare const b: B<Foo>;
>b : B<Foo>

declare const c: C<Foo>;
>c : C<Foo>

declare let thingOfInterfaces: A<Bar> | B<Baz> | C<Kwah>;
>thingOfInterfaces : A<Bar> | B<Baz> | C<Kwah>

thingOfInterfaces = a;
>thingOfInterfaces = a : A<Foo>
>thingOfInterfaces : A<Bar> | B<Baz> | C<Kwah>
>a : A<Foo>

thingOfInterfaces = b;
>thingOfInterfaces = b : B<Foo>
>thingOfInterfaces : A<Bar> | B<Baz> | C<Kwah>
>b : B<Foo>

thingOfInterfaces = c;
>thingOfInterfaces = c : C<Foo>
>thingOfInterfaces : A<Bar> | B<Baz> | C<Kwah>
>c : C<Foo>

////////

type X<T> = {
>X : X<T>

    xProp: T;
>xProp : T
}

type Y<T> = {
>Y : Y<T>

    yProp: T;
>yProp : T
}

type Z<T> = {
>Z : Z<T>

    zProp: T;
>zProp : T
}

declare const x: X<Foo>;
>x : X<Foo>

declare const y: Y<Foo>;
>y : Y<Foo>

declare const z: Z<Foo>;
>z : Z<Foo>

declare let thingOfTypeAliases: X<Bar> | Y<Baz> | Z<Kwah>;
>thingOfTypeAliases : X<Bar> | Y<Baz> | Z<Kwah>

thingOfTypeAliases = x;
>thingOfTypeAliases = x : X<Foo>
>thingOfTypeAliases : X<Bar> | Y<Baz> | Z<Kwah>
>x : X<Foo>

thingOfTypeAliases = y;
>thingOfTypeAliases = y : Y<Foo>
>thingOfTypeAliases : X<Bar> | Y<Baz> | Z<Kwah>
>y : Y<Foo>

thingOfTypeAliases = z;
>thingOfTypeAliases = z : Z<Foo>
>thingOfTypeAliases : X<Bar> | Y<Baz> | Z<Kwah>
>z : Z<Foo>