File: typeofOperatorWithStringType.js

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 (110 lines) | stat: -rw-r--r-- 2,753 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
//// [typeofOperatorWithStringType.ts]
// typeof  operator on string type
var STRING: string;
var STRING1: string[] = ["", "abc"];

function foo(): string { return "abc"; }

class A {
    public a: string;
    static foo() { return ""; }
}
module M {
    export var n: string;
}

var objA = new A();

// string type var
var ResultIsString1 = typeof STRING;
var ResultIsString2 = typeof STRING1;

// string type literal
var ResultIsString3 = typeof "";
var ResultIsString4 = typeof { x: "", y: "" };
var ResultIsString5 = typeof { x: "", y: (s: string) => { return s; } };

// string type expressions
var ResultIsString6 = typeof objA.a;
var ResultIsString7 = typeof M.n;
var ResultIsString8 = typeof STRING1[0];
var ResultIsString9 = typeof foo();
var ResultIsString10 = typeof A.foo();
var ResultIsString11 = typeof (STRING + STRING);
var ResultIsString12 = typeof STRING.charAt(0);

// multiple typeof  operators
var ResultIsString13 = typeof typeof STRING;
var ResultIsString14 = typeof typeof typeof (STRING + STRING);

// miss assignment operators
typeof "";
typeof STRING;
typeof STRING1;
typeof foo();
typeof objA.a, M.n;

// use typeof in type query
var z: string;
var x: string[];
var r: () => string;
z: typeof STRING;
x: typeof STRING1;
r: typeof foo;
var y = { a: "", b: "" };
z: typeof y.a;
z: typeof objA.a;
z: typeof A.foo;
z: typeof M.n;

//// [typeofOperatorWithStringType.js]
// typeof  operator on string type
var STRING;
var STRING1 = ["", "abc"];
function foo() { return "abc"; }
var A = /** @class */ (function () {
    function A() {
    }
    A.foo = function () { return ""; };
    return A;
}());
var M;
(function (M) {
})(M || (M = {}));
var objA = new A();
// string type var
var ResultIsString1 = typeof STRING;
var ResultIsString2 = typeof STRING1;
// string type literal
var ResultIsString3 = typeof "";
var ResultIsString4 = typeof { x: "", y: "" };
var ResultIsString5 = typeof { x: "", y: function (s) { return s; } };
// string type expressions
var ResultIsString6 = typeof objA.a;
var ResultIsString7 = typeof M.n;
var ResultIsString8 = typeof STRING1[0];
var ResultIsString9 = typeof foo();
var ResultIsString10 = typeof A.foo();
var ResultIsString11 = typeof (STRING + STRING);
var ResultIsString12 = typeof STRING.charAt(0);
// multiple typeof  operators
var ResultIsString13 = typeof typeof STRING;
var ResultIsString14 = typeof typeof typeof (STRING + STRING);
// miss assignment operators
typeof "";
typeof STRING;
typeof STRING1;
typeof foo();
typeof objA.a, M.n;
// use typeof in type query
var z;
var x;
var r;
z: typeof STRING;
x: typeof STRING1;
r: typeof foo;
var y = { a: "", b: "" };
z: typeof y.a;
z: typeof objA.a;
z: typeof A.foo;
z: typeof M.n;