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
|
=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts ===
// typeof operator on string type
var STRING: string;
>STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3))
var STRING1: string[] = ["", "abc"];
>STRING1 : Symbol(STRING1, Decl(typeofOperatorWithStringType.ts, 2, 3))
function foo(): string { return "abc"; }
>foo : Symbol(foo, Decl(typeofOperatorWithStringType.ts, 2, 36))
class A {
>A : Symbol(A, Decl(typeofOperatorWithStringType.ts, 4, 40))
public a: string;
>a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9))
static foo() { return ""; }
>foo : Symbol(A.foo, Decl(typeofOperatorWithStringType.ts, 7, 21))
}
module M {
>M : Symbol(M, Decl(typeofOperatorWithStringType.ts, 9, 1))
export var n: string;
>n : Symbol(n, Decl(typeofOperatorWithStringType.ts, 11, 14))
}
var objA = new A();
>objA : Symbol(objA, Decl(typeofOperatorWithStringType.ts, 14, 3))
>A : Symbol(A, Decl(typeofOperatorWithStringType.ts, 4, 40))
// string type var
var ResultIsString1 = typeof STRING;
>ResultIsString1 : Symbol(ResultIsString1, Decl(typeofOperatorWithStringType.ts, 17, 3))
>STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3))
var ResultIsString2 = typeof STRING1;
>ResultIsString2 : Symbol(ResultIsString2, Decl(typeofOperatorWithStringType.ts, 18, 3))
>STRING1 : Symbol(STRING1, Decl(typeofOperatorWithStringType.ts, 2, 3))
// string type literal
var ResultIsString3 = typeof "";
>ResultIsString3 : Symbol(ResultIsString3, Decl(typeofOperatorWithStringType.ts, 21, 3))
var ResultIsString4 = typeof { x: "", y: "" };
>ResultIsString4 : Symbol(ResultIsString4, Decl(typeofOperatorWithStringType.ts, 22, 3))
>x : Symbol(x, Decl(typeofOperatorWithStringType.ts, 22, 30))
>y : Symbol(y, Decl(typeofOperatorWithStringType.ts, 22, 37))
var ResultIsString5 = typeof { x: "", y: (s: string) => { return s; } };
>ResultIsString5 : Symbol(ResultIsString5, Decl(typeofOperatorWithStringType.ts, 23, 3))
>x : Symbol(x, Decl(typeofOperatorWithStringType.ts, 23, 30))
>y : Symbol(y, Decl(typeofOperatorWithStringType.ts, 23, 37))
>s : Symbol(s, Decl(typeofOperatorWithStringType.ts, 23, 42))
>s : Symbol(s, Decl(typeofOperatorWithStringType.ts, 23, 42))
// string type expressions
var ResultIsString6 = typeof objA.a;
>ResultIsString6 : Symbol(ResultIsString6, Decl(typeofOperatorWithStringType.ts, 26, 3))
>objA.a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9))
>objA : Symbol(objA, Decl(typeofOperatorWithStringType.ts, 14, 3))
>a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9))
var ResultIsString7 = typeof M.n;
>ResultIsString7 : Symbol(ResultIsString7, Decl(typeofOperatorWithStringType.ts, 27, 3))
>M.n : Symbol(M.n, Decl(typeofOperatorWithStringType.ts, 11, 14))
>M : Symbol(M, Decl(typeofOperatorWithStringType.ts, 9, 1))
>n : Symbol(M.n, Decl(typeofOperatorWithStringType.ts, 11, 14))
var ResultIsString8 = typeof STRING1[0];
>ResultIsString8 : Symbol(ResultIsString8, Decl(typeofOperatorWithStringType.ts, 28, 3))
>STRING1 : Symbol(STRING1, Decl(typeofOperatorWithStringType.ts, 2, 3))
var ResultIsString9 = typeof foo();
>ResultIsString9 : Symbol(ResultIsString9, Decl(typeofOperatorWithStringType.ts, 29, 3))
>foo : Symbol(foo, Decl(typeofOperatorWithStringType.ts, 2, 36))
var ResultIsString10 = typeof A.foo();
>ResultIsString10 : Symbol(ResultIsString10, Decl(typeofOperatorWithStringType.ts, 30, 3))
>A.foo : Symbol(A.foo, Decl(typeofOperatorWithStringType.ts, 7, 21))
>A : Symbol(A, Decl(typeofOperatorWithStringType.ts, 4, 40))
>foo : Symbol(A.foo, Decl(typeofOperatorWithStringType.ts, 7, 21))
var ResultIsString11 = typeof (STRING + STRING);
>ResultIsString11 : Symbol(ResultIsString11, Decl(typeofOperatorWithStringType.ts, 31, 3))
>STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3))
>STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3))
var ResultIsString12 = typeof STRING.charAt(0);
>ResultIsString12 : Symbol(ResultIsString12, Decl(typeofOperatorWithStringType.ts, 32, 3))
>STRING.charAt : Symbol(String.charAt, Decl(lib.es5.d.ts, --, --))
>STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3))
>charAt : Symbol(String.charAt, Decl(lib.es5.d.ts, --, --))
// multiple typeof operators
var ResultIsString13 = typeof typeof STRING;
>ResultIsString13 : Symbol(ResultIsString13, Decl(typeofOperatorWithStringType.ts, 35, 3))
>STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3))
var ResultIsString14 = typeof typeof typeof (STRING + STRING);
>ResultIsString14 : Symbol(ResultIsString14, Decl(typeofOperatorWithStringType.ts, 36, 3))
>STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3))
>STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3))
// miss assignment operators
typeof "";
typeof STRING;
>STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3))
typeof STRING1;
>STRING1 : Symbol(STRING1, Decl(typeofOperatorWithStringType.ts, 2, 3))
typeof foo();
>foo : Symbol(foo, Decl(typeofOperatorWithStringType.ts, 2, 36))
typeof objA.a, M.n;
>objA.a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9))
>objA : Symbol(objA, Decl(typeofOperatorWithStringType.ts, 14, 3))
>a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9))
>M.n : Symbol(M.n, Decl(typeofOperatorWithStringType.ts, 11, 14))
>M : Symbol(M, Decl(typeofOperatorWithStringType.ts, 9, 1))
>n : Symbol(M.n, Decl(typeofOperatorWithStringType.ts, 11, 14))
// use typeof in type query
var z: string;
>z : Symbol(z, Decl(typeofOperatorWithStringType.ts, 46, 3))
var x: string[];
>x : Symbol(x, Decl(typeofOperatorWithStringType.ts, 47, 3))
var r: () => string;
>r : Symbol(r, Decl(typeofOperatorWithStringType.ts, 48, 3))
z: typeof STRING;
>STRING : Symbol(STRING, Decl(typeofOperatorWithStringType.ts, 1, 3))
x: typeof STRING1;
>STRING1 : Symbol(STRING1, Decl(typeofOperatorWithStringType.ts, 2, 3))
r: typeof foo;
>foo : Symbol(foo, Decl(typeofOperatorWithStringType.ts, 2, 36))
var y = { a: "", b: "" };
>y : Symbol(y, Decl(typeofOperatorWithStringType.ts, 52, 3))
>a : Symbol(a, Decl(typeofOperatorWithStringType.ts, 52, 9))
>b : Symbol(b, Decl(typeofOperatorWithStringType.ts, 52, 16))
z: typeof y.a;
>y.a : Symbol(a, Decl(typeofOperatorWithStringType.ts, 52, 9))
>y : Symbol(y, Decl(typeofOperatorWithStringType.ts, 52, 3))
>a : Symbol(a, Decl(typeofOperatorWithStringType.ts, 52, 9))
z: typeof objA.a;
>objA.a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9))
>objA : Symbol(objA, Decl(typeofOperatorWithStringType.ts, 14, 3))
>a : Symbol(A.a, Decl(typeofOperatorWithStringType.ts, 6, 9))
z: typeof A.foo;
>A.foo : Symbol(A.foo, Decl(typeofOperatorWithStringType.ts, 7, 21))
>A : Symbol(A, Decl(typeofOperatorWithStringType.ts, 4, 40))
>foo : Symbol(A.foo, Decl(typeofOperatorWithStringType.ts, 7, 21))
z: typeof M.n;
>M.n : Symbol(M.n, Decl(typeofOperatorWithStringType.ts, 11, 14))
>M : Symbol(M, Decl(typeofOperatorWithStringType.ts, 9, 1))
>n : Symbol(M.n, Decl(typeofOperatorWithStringType.ts, 11, 14))
|