File: typeofOperatorWithAnyOtherType.types

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (297 lines) | stat: -rw-r--r-- 10,475 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
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts ===
// typeof  operator on any type

var ANY: any;
>ANY : any

var ANY1;
>ANY1 : any

var ANY2: any[] = ["", ""];
>ANY2 : any[]
>["", ""] : string[]
>"" : ""
>"" : ""

var obj: () => {}
>obj : () => {}

var obj1 = { x: "a", y: () => { }};
>obj1 : { x: string; y: () => void; }
>{ x: "a", y: () => { }} : { x: string; y: () => void; }
>x : string
>"a" : "a"
>y : () => void
>() => { } : () => void

function foo(): any {
>foo : () => any

    var a;
>a : any

    return a;
>a : any
}
class A {
>A : A

    public a: any;
>a : any

    static foo() {
>foo : () => any

        var a;
>a : any

        return a;
>a : any
    }
}
module M {
>M : typeof M

    export var n: any;
>n : any
}
var objA = new A();
>objA : A
>new A() : A
>A : typeof A

// any type var
var ResultIsString1 = typeof ANY1;
>ResultIsString1 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof ANY1 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ANY1 : any

var ResultIsString2 = typeof ANY2;
>ResultIsString2 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof ANY2 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ANY2 : any[]

var ResultIsString3 = typeof A;
>ResultIsString3 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof A : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>A : typeof A

var ResultIsString4 = typeof M;
>ResultIsString4 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof M : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>M : typeof M

var ResultIsString5 = typeof obj;
>ResultIsString5 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof obj : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>obj : () => {}

var ResultIsString6 = typeof obj1;
>ResultIsString6 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof obj1 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>obj1 : { x: string; y: () => void; }

// any type literal
var ResultIsString7 = typeof undefined;
>ResultIsString7 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof undefined : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>undefined : undefined

var ResultIsString8 = typeof null;
>ResultIsString8 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof null : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>null : null

var ResultIsString9 = typeof {};
>ResultIsString9 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof {} : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>{} : {}

// any type expressions
var ResultIsString10 = typeof ANY2[0];
>ResultIsString10 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof ANY2[0] : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ANY2[0] : any
>ANY2 : any[]
>0 : 0

var ResultIsString11 = typeof objA.a;
>ResultIsString11 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof objA.a : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>objA.a : any
>objA : A
>a : any

var ResultIsString12 = typeof obj1.x;
>ResultIsString12 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof obj1.x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>obj1.x : string
>obj1 : { x: string; y: () => void; }
>x : string

var ResultIsString13 = typeof M.n;
>ResultIsString13 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof M.n : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>M.n : any
>M : typeof M
>n : any

var ResultIsString14 = typeof foo();
>ResultIsString14 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof foo() : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>foo() : any
>foo : () => any

var ResultIsString15 = typeof A.foo();
>ResultIsString15 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof A.foo() : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>A.foo() : any
>A.foo : () => any
>A : typeof A
>foo : () => any

var ResultIsString16 = typeof (ANY + ANY1);
>ResultIsString16 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof (ANY + ANY1) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(ANY + ANY1) : any
>ANY + ANY1 : any
>ANY : any
>ANY1 : any

var ResultIsString17 = typeof (null + undefined);
>ResultIsString17 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof (null + undefined) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(null + undefined) : any
>null + undefined : any
>null : null
>undefined : undefined

var ResultIsString18 = typeof (null + null);
>ResultIsString18 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof (null + null) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(null + null) : any
>null + null : any
>null : null
>null : null

var ResultIsString19 = typeof (undefined + undefined);
>ResultIsString19 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof (undefined + undefined) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(undefined + undefined) : any
>undefined + undefined : any
>undefined : undefined
>undefined : undefined

// multiple typeof  operators
var ResultIsString20 = typeof typeof ANY;
>ResultIsString20 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof typeof ANY : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof ANY : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ANY : any

var ResultIsString21 = typeof typeof typeof (ANY + ANY1);
>ResultIsString21 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof typeof typeof (ANY + ANY1) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof typeof (ANY + ANY1) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof (ANY + ANY1) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(ANY + ANY1) : any
>ANY + ANY1 : any
>ANY : any
>ANY1 : any

// miss assignment operators
typeof ANY;
>typeof ANY : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ANY : any

typeof ANY1;
>typeof ANY1 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ANY1 : any

typeof ANY2[0];
>typeof ANY2[0] : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ANY2[0] : any
>ANY2 : any[]
>0 : 0

typeof ANY, ANY1;
>typeof ANY, ANY1 : any
>typeof ANY : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ANY : any
>ANY1 : any

typeof obj1;
>typeof obj1 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>obj1 : { x: string; y: () => void; }

typeof obj1.x;
>typeof obj1.x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>obj1.x : string
>obj1 : { x: string; y: () => void; }
>x : string

typeof objA.a;
>typeof objA.a : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>objA.a : any
>objA : A
>a : any

typeof M.n;
>typeof M.n : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>M.n : any
>M : typeof M
>n : any

// use typeof in type query
var z: any;
>z : any

var x: any[];
>x : any[]

var r: () => any;
>r : () => any

z: typeof ANY;
>z : any
>typeof ANY : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ANY : any

x: typeof ANY2;
>x : any
>typeof ANY2 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ANY2 : any[]

r: typeof foo;
>r : any
>typeof foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>foo : () => any

z: typeof objA.a;
>z : any
>typeof objA.a : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>objA.a : any
>objA : A
>a : any

z: typeof A.foo;
>z : any
>typeof A.foo : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>A.foo : () => any
>A : typeof A
>foo : () => any

z: typeof M.n;
>z : any
>typeof M.n : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>M.n : any
>M : typeof M
>n : any

z: typeof obj1.x;
>z : any
>typeof obj1.x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>obj1.x : string
>obj1 : { x: string; y: () => void; }
>x : string