File: divergentAccessorsTypes1.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (208 lines) | stat: -rw-r--r-- 3,655 bytes parent folder | download | duplicates (3)
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
=== tests/cases/compiler/divergentAccessorsTypes1.ts ===
class Test1 {
>Test1 : Test1

    get foo(): string { return "" }
>foo : string
>"" : ""

    set foo(s: string | number) {
>foo : string
>s : string | number

        let a = s as string;
>a : string
>s as string : string
>s : string | number

        let b = s as number;
>b : number
>s as number : number
>s : string | number
    }

    get bar(): string | number { return "" }
>bar : string | number
>"" : ""

    set bar(s: string | number | boolean) {
>bar : string | number
>s : string | number | boolean
    }
}

interface Test2 {
    get foo(): string;
>foo : string

    set foo(s: string | number);
>foo : string
>s : string | number

    get bar(): string | number;
>bar : string | number

    set bar(s: string | number | boolean);
>bar : string | number
>s : string | number | boolean
}

type Test3 = {
>Test3 : { foo: string; bar: string | number; }

    get foo(): string;
>foo : string

    set foo(s: string | number);
>foo : string
>s : string | number

    get bar(): string | number;
>bar : string | number

    set bar(s: string | number | boolean);
>bar : string | number
>s : string | number | boolean

};

{
    const t = new Test1();
>t : Test1
>new Test1() : Test1
>Test1 : typeof Test1

    t.foo = 32;
>t.foo = 32 : 32
>t.foo : string | number
>t : Test1
>foo : string | number
>32 : 32

    let m: string = t.foo;
>m : string
>t.foo : string
>t : Test1
>foo : string

    // See how CFA interacts with out-of-type writes
    t.bar = 42;
>t.bar = 42 : 42
>t.bar : string | number | boolean
>t : Test1
>bar : string | number | boolean
>42 : 42

    let n: number = t.bar;
>n : number
>t.bar : number
>t : Test1
>bar : number

    t.bar = false;
>t.bar = false : false
>t.bar : string | number | boolean
>t : Test1
>bar : string | number | boolean
>false : false

    let o = t.bar;
>o : string | number
>t.bar : string | number
>t : Test1
>bar : string | number
}

{
    const t = {} as Test2;
>t : Test2
>{} as Test2 : Test2
>{} : {}

    t.foo = 32;
>t.foo = 32 : 32
>t.foo : string | number
>t : Test2
>foo : string | number
>32 : 32

    let m: string = t.foo;
>m : string
>t.foo : string
>t : Test2
>foo : string

    // See how CFA interacts with out-of-type writes
    t.bar = 42;
>t.bar = 42 : 42
>t.bar : string | number | boolean
>t : Test2
>bar : string | number | boolean
>42 : 42

    let n: number = t.bar;
>n : number
>t.bar : number
>t : Test2
>bar : number

    t.bar = false;
>t.bar = false : false
>t.bar : string | number | boolean
>t : Test2
>bar : string | number | boolean
>false : false

    let o = t.bar;
>o : string | number
>t.bar : string | number
>t : Test2
>bar : string | number
}

{
    const t = {} as Test3;
>t : Test3
>{} as Test3 : Test3
>{} : {}

    t.foo = 32;
>t.foo = 32 : 32
>t.foo : string | number
>t : Test3
>foo : string | number
>32 : 32

    let m: string = t.foo;
>m : string
>t.foo : string
>t : Test3
>foo : string

    // See how CFA interacts with out-of-type writes
    t.bar = 42;
>t.bar = 42 : 42
>t.bar : string | number | boolean
>t : Test3
>bar : string | number | boolean
>42 : 42

    let n: number = t.bar;
>n : number
>t.bar : number
>t : Test3
>bar : number

    t.bar = false;
>t.bar = false : false
>t.bar : string | number | boolean
>t : Test3
>bar : string | number | boolean
>false : false

    let o = t.bar;
>o : string | number
>t.bar : string | number
>t : Test3
>bar : string | number
}