File: unionTypeMembers.symbols

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 (182 lines) | stat: -rw-r--r-- 10,074 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
=== tests/cases/conformance/types/union/unionTypeMembers.ts ===
interface I1<T> {
>I1 : Symbol(I1, Decl(unionTypeMembers.ts, 0, 0))
>T : Symbol(T, Decl(unionTypeMembers.ts, 0, 13))

    commonMethodType(a: string): string;
>commonMethodType : Symbol(I1.commonMethodType, Decl(unionTypeMembers.ts, 0, 17))
>a : Symbol(a, Decl(unionTypeMembers.ts, 1, 21))

    commonPropertyType: string;
>commonPropertyType : Symbol(I1.commonPropertyType, Decl(unionTypeMembers.ts, 1, 40))

    commonMethodDifferentParameterType(a: string): string;
>commonMethodDifferentParameterType : Symbol(I1.commonMethodDifferentParameterType, Decl(unionTypeMembers.ts, 2, 31))
>a : Symbol(a, Decl(unionTypeMembers.ts, 4, 39))

    commonMethodDifferentReturnType(a: string): string;
>commonMethodDifferentReturnType : Symbol(I1.commonMethodDifferentReturnType, Decl(unionTypeMembers.ts, 4, 58))
>a : Symbol(a, Decl(unionTypeMembers.ts, 5, 36))

    commonPropertyDifferenType: string;
>commonPropertyDifferenType : Symbol(I1.commonPropertyDifferenType, Decl(unionTypeMembers.ts, 5, 55))

    commonMethodWithTypeParameter(a: T): T;
>commonMethodWithTypeParameter : Symbol(I1.commonMethodWithTypeParameter, Decl(unionTypeMembers.ts, 6, 39))
>a : Symbol(a, Decl(unionTypeMembers.ts, 8, 34))
>T : Symbol(T, Decl(unionTypeMembers.ts, 0, 13))
>T : Symbol(T, Decl(unionTypeMembers.ts, 0, 13))

    commonMethodWithOwnTypeParameter<U>(a: U): U;
>commonMethodWithOwnTypeParameter : Symbol(I1.commonMethodWithOwnTypeParameter, Decl(unionTypeMembers.ts, 8, 43))
>U : Symbol(U, Decl(unionTypeMembers.ts, 9, 37))
>a : Symbol(a, Decl(unionTypeMembers.ts, 9, 40))
>U : Symbol(U, Decl(unionTypeMembers.ts, 9, 37))
>U : Symbol(U, Decl(unionTypeMembers.ts, 9, 37))

    methodOnlyInI1(a: string): string;
>methodOnlyInI1 : Symbol(I1.methodOnlyInI1, Decl(unionTypeMembers.ts, 9, 49))
>a : Symbol(a, Decl(unionTypeMembers.ts, 11, 19))

    propertyOnlyInI1: string;
>propertyOnlyInI1 : Symbol(I1.propertyOnlyInI1, Decl(unionTypeMembers.ts, 11, 38))
}

interface I2<T> {
>I2 : Symbol(I2, Decl(unionTypeMembers.ts, 13, 1))
>T : Symbol(T, Decl(unionTypeMembers.ts, 15, 13))

    commonMethodType(a: string): string;
>commonMethodType : Symbol(I2.commonMethodType, Decl(unionTypeMembers.ts, 15, 17))
>a : Symbol(a, Decl(unionTypeMembers.ts, 16, 21))

    commonPropertyType: string;
>commonPropertyType : Symbol(I2.commonPropertyType, Decl(unionTypeMembers.ts, 16, 40))

    commonMethodDifferentParameterType(a: number): number;
>commonMethodDifferentParameterType : Symbol(I2.commonMethodDifferentParameterType, Decl(unionTypeMembers.ts, 17, 31))
>a : Symbol(a, Decl(unionTypeMembers.ts, 19, 39))

    commonMethodDifferentReturnType(a: string): number;
>commonMethodDifferentReturnType : Symbol(I2.commonMethodDifferentReturnType, Decl(unionTypeMembers.ts, 19, 58))
>a : Symbol(a, Decl(unionTypeMembers.ts, 20, 36))

    commonPropertyDifferenType: number;
>commonPropertyDifferenType : Symbol(I2.commonPropertyDifferenType, Decl(unionTypeMembers.ts, 20, 55))

    commonMethodWithTypeParameter(a: T): T;
>commonMethodWithTypeParameter : Symbol(I2.commonMethodWithTypeParameter, Decl(unionTypeMembers.ts, 21, 39))
>a : Symbol(a, Decl(unionTypeMembers.ts, 23, 34))
>T : Symbol(T, Decl(unionTypeMembers.ts, 15, 13))
>T : Symbol(T, Decl(unionTypeMembers.ts, 15, 13))

    commonMethodWithOwnTypeParameter<U>(a: U): U;
>commonMethodWithOwnTypeParameter : Symbol(I2.commonMethodWithOwnTypeParameter, Decl(unionTypeMembers.ts, 23, 43))
>U : Symbol(U, Decl(unionTypeMembers.ts, 24, 37))
>a : Symbol(a, Decl(unionTypeMembers.ts, 24, 40))
>U : Symbol(U, Decl(unionTypeMembers.ts, 24, 37))
>U : Symbol(U, Decl(unionTypeMembers.ts, 24, 37))

    methodOnlyInI2(a: string): string;
>methodOnlyInI2 : Symbol(I2.methodOnlyInI2, Decl(unionTypeMembers.ts, 24, 49))
>a : Symbol(a, Decl(unionTypeMembers.ts, 26, 19))

    propertyOnlyInI2: string;
>propertyOnlyInI2 : Symbol(I2.propertyOnlyInI2, Decl(unionTypeMembers.ts, 26, 38))
}

// a union type U has those members that are present in every one of its constituent types, 
// with types that are unions of the respective members in the constituent types
var x : I1<number> | I2<number>;
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))
>I1 : Symbol(I1, Decl(unionTypeMembers.ts, 0, 0))
>I2 : Symbol(I2, Decl(unionTypeMembers.ts, 13, 1))

var str: string;
>str : Symbol(str, Decl(unionTypeMembers.ts, 33, 3))

var num: number;
>num : Symbol(num, Decl(unionTypeMembers.ts, 34, 3))

var strOrNum: string | number;
>strOrNum : Symbol(strOrNum, Decl(unionTypeMembers.ts, 35, 3))

// If each type in U has a property P, U has a property P of a union type of the types of P from each type in U.
str = x.commonPropertyType; // string
>str : Symbol(str, Decl(unionTypeMembers.ts, 33, 3))
>x.commonPropertyType : Symbol(commonPropertyType, Decl(unionTypeMembers.ts, 1, 40), Decl(unionTypeMembers.ts, 16, 40))
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))
>commonPropertyType : Symbol(commonPropertyType, Decl(unionTypeMembers.ts, 1, 40), Decl(unionTypeMembers.ts, 16, 40))

str = x.commonMethodType(str); // (a: string) => string so result should be string
>str : Symbol(str, Decl(unionTypeMembers.ts, 33, 3))
>x.commonMethodType : Symbol(commonMethodType, Decl(unionTypeMembers.ts, 0, 17), Decl(unionTypeMembers.ts, 15, 17))
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))
>commonMethodType : Symbol(commonMethodType, Decl(unionTypeMembers.ts, 0, 17), Decl(unionTypeMembers.ts, 15, 17))
>str : Symbol(str, Decl(unionTypeMembers.ts, 33, 3))

strOrNum = x.commonPropertyDifferenType;
>strOrNum : Symbol(strOrNum, Decl(unionTypeMembers.ts, 35, 3))
>x.commonPropertyDifferenType : Symbol(commonPropertyDifferenType, Decl(unionTypeMembers.ts, 5, 55), Decl(unionTypeMembers.ts, 20, 55))
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))
>commonPropertyDifferenType : Symbol(commonPropertyDifferenType, Decl(unionTypeMembers.ts, 5, 55), Decl(unionTypeMembers.ts, 20, 55))

strOrNum = x.commonMethodDifferentReturnType(str); // string | union
>strOrNum : Symbol(strOrNum, Decl(unionTypeMembers.ts, 35, 3))
>x.commonMethodDifferentReturnType : Symbol(commonMethodDifferentReturnType, Decl(unionTypeMembers.ts, 4, 58), Decl(unionTypeMembers.ts, 19, 58))
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))
>commonMethodDifferentReturnType : Symbol(commonMethodDifferentReturnType, Decl(unionTypeMembers.ts, 4, 58), Decl(unionTypeMembers.ts, 19, 58))
>str : Symbol(str, Decl(unionTypeMembers.ts, 33, 3))

x.commonMethodDifferentParameterType; // No error - property exists
>x.commonMethodDifferentParameterType : Symbol(commonMethodDifferentParameterType, Decl(unionTypeMembers.ts, 2, 31), Decl(unionTypeMembers.ts, 17, 31))
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))
>commonMethodDifferentParameterType : Symbol(commonMethodDifferentParameterType, Decl(unionTypeMembers.ts, 2, 31), Decl(unionTypeMembers.ts, 17, 31))

x.commonMethodDifferentParameterType(strOrNum); // error - no call signatures because the type of this property is ((a: string) => string) | (a: number) => number
>x.commonMethodDifferentParameterType : Symbol(commonMethodDifferentParameterType, Decl(unionTypeMembers.ts, 2, 31), Decl(unionTypeMembers.ts, 17, 31))
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))
>commonMethodDifferentParameterType : Symbol(commonMethodDifferentParameterType, Decl(unionTypeMembers.ts, 2, 31), Decl(unionTypeMembers.ts, 17, 31))
>strOrNum : Symbol(strOrNum, Decl(unionTypeMembers.ts, 35, 3))

                                                // and the call signatures arent identical
num = x.commonMethodWithTypeParameter(num);
>num : Symbol(num, Decl(unionTypeMembers.ts, 34, 3))
>x.commonMethodWithTypeParameter : Symbol(commonMethodWithTypeParameter, Decl(unionTypeMembers.ts, 6, 39), Decl(unionTypeMembers.ts, 21, 39))
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))
>commonMethodWithTypeParameter : Symbol(commonMethodWithTypeParameter, Decl(unionTypeMembers.ts, 6, 39), Decl(unionTypeMembers.ts, 21, 39))
>num : Symbol(num, Decl(unionTypeMembers.ts, 34, 3))

num = x.commonMethodWithOwnTypeParameter(num);
>num : Symbol(num, Decl(unionTypeMembers.ts, 34, 3))
>x.commonMethodWithOwnTypeParameter : Symbol(commonMethodWithOwnTypeParameter, Decl(unionTypeMembers.ts, 8, 43), Decl(unionTypeMembers.ts, 23, 43))
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))
>commonMethodWithOwnTypeParameter : Symbol(commonMethodWithOwnTypeParameter, Decl(unionTypeMembers.ts, 8, 43), Decl(unionTypeMembers.ts, 23, 43))
>num : Symbol(num, Decl(unionTypeMembers.ts, 34, 3))

str = x.commonMethodWithOwnTypeParameter(str);
>str : Symbol(str, Decl(unionTypeMembers.ts, 33, 3))
>x.commonMethodWithOwnTypeParameter : Symbol(commonMethodWithOwnTypeParameter, Decl(unionTypeMembers.ts, 8, 43), Decl(unionTypeMembers.ts, 23, 43))
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))
>commonMethodWithOwnTypeParameter : Symbol(commonMethodWithOwnTypeParameter, Decl(unionTypeMembers.ts, 8, 43), Decl(unionTypeMembers.ts, 23, 43))
>str : Symbol(str, Decl(unionTypeMembers.ts, 33, 3))

strOrNum = x.commonMethodWithOwnTypeParameter(strOrNum);
>strOrNum : Symbol(strOrNum, Decl(unionTypeMembers.ts, 35, 3))
>x.commonMethodWithOwnTypeParameter : Symbol(commonMethodWithOwnTypeParameter, Decl(unionTypeMembers.ts, 8, 43), Decl(unionTypeMembers.ts, 23, 43))
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))
>commonMethodWithOwnTypeParameter : Symbol(commonMethodWithOwnTypeParameter, Decl(unionTypeMembers.ts, 8, 43), Decl(unionTypeMembers.ts, 23, 43))
>strOrNum : Symbol(strOrNum, Decl(unionTypeMembers.ts, 35, 3))

x.propertyOnlyInI1; // error
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))

x.propertyOnlyInI2; // error
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))

x.methodOnlyInI1("hello"); // error
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))

x.methodOnlyInI2(10); // error
>x : Symbol(x, Decl(unionTypeMembers.ts, 32, 3))