File: typeofOperatorWithEnumType.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 (99 lines) | stat: -rw-r--r-- 3,926 bytes parent folder | download
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
=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithEnumType.ts ===
// typeof  operator on enum type

enum ENUM { };
>ENUM : ENUM

enum ENUM1 { A, B, "" };
>ENUM1 : ENUM1
>A : ENUM1.A
>B : ENUM1.B
>"" : ENUM1.

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

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

// enum type expressions
var ResultIsString3 = typeof ENUM1["A"];
>ResultIsString3 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof ENUM1["A"] : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ENUM1["A"] : ENUM1.A
>ENUM1 : typeof ENUM1
>"A" : "A"

var ResultIsString4 = typeof (ENUM[0] + ENUM1["B"]);
>ResultIsString4 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof (ENUM[0] + ENUM1["B"]) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(ENUM[0] + ENUM1["B"]) : string
>ENUM[0] + ENUM1["B"] : string
>ENUM[0] : string
>ENUM : typeof ENUM
>0 : 0
>ENUM1["B"] : ENUM1.B
>ENUM1 : typeof ENUM1
>"B" : "B"

// multiple typeof  operators
var ResultIsString5 = typeof typeof ENUM;
>ResultIsString5 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof typeof ENUM : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof ENUM : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ENUM : typeof ENUM

var ResultIsString6 = typeof typeof typeof (ENUM[0] + ENUM1.B);
>ResultIsString6 : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof typeof typeof (ENUM[0] + ENUM1.B) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof typeof (ENUM[0] + ENUM1.B) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>typeof (ENUM[0] + ENUM1.B) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(ENUM[0] + ENUM1.B) : string
>ENUM[0] + ENUM1.B : string
>ENUM[0] : string
>ENUM : typeof ENUM
>0 : 0
>ENUM1.B : ENUM1.B
>ENUM1 : typeof ENUM1
>B : ENUM1.B

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

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

typeof ENUM1["B"];
>typeof ENUM1["B"] : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ENUM1["B"] : ENUM1.B
>ENUM1 : typeof ENUM1
>"B" : "B"

typeof ENUM, ENUM1;
>typeof ENUM, ENUM1 : typeof ENUM1
>typeof ENUM : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>ENUM : typeof ENUM
>ENUM1 : typeof ENUM1

// use typeof in type query
enum z { };
>z : z

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

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