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 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
|
=== tests/cases/conformance/expressions/propertyAccess/propertyAccess.ts ===
class A {
>A : Symbol(A, Decl(propertyAccess.ts, 0, 0))
a: number;
>a : Symbol(A.a, Decl(propertyAccess.ts, 0, 9))
}
class B extends A {
>B : Symbol(B, Decl(propertyAccess.ts, 2, 1))
>A : Symbol(A, Decl(propertyAccess.ts, 0, 0))
b: number;
>b : Symbol(B.b, Decl(propertyAccess.ts, 3, 19))
}
enum Compass {
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
North, South, East, West
>North : Symbol(Compass.North, Decl(propertyAccess.ts, 6, 14))
>South : Symbol(Compass.South, Decl(propertyAccess.ts, 7, 10))
>East : Symbol(Compass.East, Decl(propertyAccess.ts, 7, 17))
>West : Symbol(Compass.West, Decl(propertyAccess.ts, 7, 23))
}
var numIndex: { [n: number]: string } = { 3: 'three', 'three': 'three' };
>numIndex : Symbol(numIndex, Decl(propertyAccess.ts, 10, 3))
>n : Symbol(n, Decl(propertyAccess.ts, 10, 17))
>3 : Symbol(3, Decl(propertyAccess.ts, 10, 41))
>'three' : Symbol('three', Decl(propertyAccess.ts, 10, 53))
var strIndex: { [n: string]: Compass } = { 'N': Compass.North, 'E': Compass.East };
>strIndex : Symbol(strIndex, Decl(propertyAccess.ts, 11, 3))
>n : Symbol(n, Decl(propertyAccess.ts, 11, 17))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
>'N' : Symbol('N', Decl(propertyAccess.ts, 11, 42))
>Compass.North : Symbol(Compass.North, Decl(propertyAccess.ts, 6, 14))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
>North : Symbol(Compass.North, Decl(propertyAccess.ts, 6, 14))
>'E' : Symbol('E', Decl(propertyAccess.ts, 11, 62))
>Compass.East : Symbol(Compass.East, Decl(propertyAccess.ts, 7, 17))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
>East : Symbol(Compass.East, Decl(propertyAccess.ts, 7, 17))
var bothIndex:
>bothIndex : Symbol(bothIndex, Decl(propertyAccess.ts, 12, 3))
{
[n: string]: A;
>n : Symbol(n, Decl(propertyAccess.ts, 14, 9))
>A : Symbol(A, Decl(propertyAccess.ts, 0, 0))
[m: number]: B;
>m : Symbol(m, Decl(propertyAccess.ts, 15, 9))
>B : Symbol(B, Decl(propertyAccess.ts, 2, 1))
};
function noIndex() { }
>noIndex : Symbol(noIndex, Decl(propertyAccess.ts, 16, 6))
var obj = {
>obj : Symbol(obj, Decl(propertyAccess.ts, 20, 3))
10: 'ten',
>10 : Symbol(10, Decl(propertyAccess.ts, 20, 11))
x: 'hello',
>x : Symbol(x, Decl(propertyAccess.ts, 21, 14))
y: 32,
>y : Symbol(y, Decl(propertyAccess.ts, 22, 15))
z: { n: 'world', m: 15, o: () => false },
>z : Symbol(z, Decl(propertyAccess.ts, 23, 10))
>n : Symbol(n, Decl(propertyAccess.ts, 24, 8))
>m : Symbol(m, Decl(propertyAccess.ts, 24, 20))
>o : Symbol(o, Decl(propertyAccess.ts, 24, 27))
'literal property': 100
>'literal property' : Symbol('literal property', Decl(propertyAccess.ts, 24, 45))
};
var anyVar: any = {};
>anyVar : Symbol(anyVar, Decl(propertyAccess.ts, 27, 3))
var stringOrNumber: string | number;
>stringOrNumber : Symbol(stringOrNumber, Decl(propertyAccess.ts, 28, 3))
var someObject: { name: string };
>someObject : Symbol(someObject, Decl(propertyAccess.ts, 29, 3))
>name : Symbol(name, Decl(propertyAccess.ts, 29, 17))
// Assign to a property access
obj.y = 4;
>obj.y : Symbol(y, Decl(propertyAccess.ts, 22, 15))
>obj : Symbol(obj, Decl(propertyAccess.ts, 20, 3))
>y : Symbol(y, Decl(propertyAccess.ts, 22, 15))
// Property access on value of type 'any'
anyVar.x = anyVar.y = obj.x = anyVar.z;
>anyVar : Symbol(anyVar, Decl(propertyAccess.ts, 27, 3))
>anyVar : Symbol(anyVar, Decl(propertyAccess.ts, 27, 3))
>obj.x : Symbol(x, Decl(propertyAccess.ts, 21, 14))
>obj : Symbol(obj, Decl(propertyAccess.ts, 20, 3))
>x : Symbol(x, Decl(propertyAccess.ts, 21, 14))
>anyVar : Symbol(anyVar, Decl(propertyAccess.ts, 27, 3))
// Dotted property access of property that exists
var aa = obj.x;
>aa : Symbol(aa, Decl(propertyAccess.ts, 38, 3))
>obj.x : Symbol(x, Decl(propertyAccess.ts, 21, 14))
>obj : Symbol(obj, Decl(propertyAccess.ts, 20, 3))
>x : Symbol(x, Decl(propertyAccess.ts, 21, 14))
// Dotted property access of property that exists on value's apparent type
var bb = obj.hasOwnProperty;
>bb : Symbol(bb, Decl(propertyAccess.ts, 41, 3))
>obj.hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es5.d.ts, --, --))
>obj : Symbol(obj, Decl(propertyAccess.ts, 20, 3))
>hasOwnProperty : Symbol(Object.hasOwnProperty, Decl(lib.es5.d.ts, --, --))
// Dotted property access of property that doesn't exist on value's apparent type
var cc = obj.qqq; // error
>cc : Symbol(cc, Decl(propertyAccess.ts, 44, 3))
>obj : Symbol(obj, Decl(propertyAccess.ts, 20, 3))
// Bracket notation property access using string literal value on type with property of that literal name
var dd = obj['literal property'];
>dd : Symbol(dd, Decl(propertyAccess.ts, 47, 3), Decl(propertyAccess.ts, 48, 3))
>obj : Symbol(obj, Decl(propertyAccess.ts, 20, 3))
>'literal property' : Symbol('literal property', Decl(propertyAccess.ts, 24, 45))
var dd: number;
>dd : Symbol(dd, Decl(propertyAccess.ts, 47, 3), Decl(propertyAccess.ts, 48, 3))
// Bracket notation property access using string literal value on type without property of that literal name
var ee = obj['wa wa wa wa wa'];
>ee : Symbol(ee, Decl(propertyAccess.ts, 51, 3), Decl(propertyAccess.ts, 52, 3))
>obj : Symbol(obj, Decl(propertyAccess.ts, 20, 3))
var ee: any;
>ee : Symbol(ee, Decl(propertyAccess.ts, 51, 3), Decl(propertyAccess.ts, 52, 3))
// Bracket notation property access using numeric string literal value on type with property of that literal name
var ff = obj['10'];
>ff : Symbol(ff, Decl(propertyAccess.ts, 55, 3), Decl(propertyAccess.ts, 56, 3))
>obj : Symbol(obj, Decl(propertyAccess.ts, 20, 3))
>'10' : Symbol(10, Decl(propertyAccess.ts, 20, 11))
var ff: string;
>ff : Symbol(ff, Decl(propertyAccess.ts, 55, 3), Decl(propertyAccess.ts, 56, 3))
// Bracket notation property access using numeric string literal value on type without property of that literal name
var gg = obj['1'];
>gg : Symbol(gg, Decl(propertyAccess.ts, 59, 3), Decl(propertyAccess.ts, 60, 3))
>obj : Symbol(obj, Decl(propertyAccess.ts, 20, 3))
var gg: any;
>gg : Symbol(gg, Decl(propertyAccess.ts, 59, 3), Decl(propertyAccess.ts, 60, 3))
// Bracket notation property access using numeric value on type with numeric index signature
var hh = numIndex[3.0];
>hh : Symbol(hh, Decl(propertyAccess.ts, 63, 3), Decl(propertyAccess.ts, 64, 3))
>numIndex : Symbol(numIndex, Decl(propertyAccess.ts, 10, 3))
var hh: string;
>hh : Symbol(hh, Decl(propertyAccess.ts, 63, 3), Decl(propertyAccess.ts, 64, 3))
// Bracket notation property access using enum value on type with numeric index signature
var ii = numIndex[Compass.South];
>ii : Symbol(ii, Decl(propertyAccess.ts, 67, 3), Decl(propertyAccess.ts, 68, 3))
>numIndex : Symbol(numIndex, Decl(propertyAccess.ts, 10, 3))
>Compass.South : Symbol(Compass.South, Decl(propertyAccess.ts, 7, 10))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
>South : Symbol(Compass.South, Decl(propertyAccess.ts, 7, 10))
var ii: string;
>ii : Symbol(ii, Decl(propertyAccess.ts, 67, 3), Decl(propertyAccess.ts, 68, 3))
// Bracket notation property access using value of type 'any' on type with numeric index signature
var jj = numIndex[anyVar];
>jj : Symbol(jj, Decl(propertyAccess.ts, 71, 3), Decl(propertyAccess.ts, 72, 3))
>numIndex : Symbol(numIndex, Decl(propertyAccess.ts, 10, 3))
>anyVar : Symbol(anyVar, Decl(propertyAccess.ts, 27, 3))
var jj: string;
>jj : Symbol(jj, Decl(propertyAccess.ts, 71, 3), Decl(propertyAccess.ts, 72, 3))
// Bracket notation property access using string value on type with numeric index signature
var kk = numIndex['what'];
>kk : Symbol(kk, Decl(propertyAccess.ts, 75, 3), Decl(propertyAccess.ts, 76, 3))
>numIndex : Symbol(numIndex, Decl(propertyAccess.ts, 10, 3))
var kk: any;
>kk : Symbol(kk, Decl(propertyAccess.ts, 75, 3), Decl(propertyAccess.ts, 76, 3))
// Bracket notation property access using value of other type on type with numeric index signature and no string index signature
var ll = numIndex[someObject]; // Error
>ll : Symbol(ll, Decl(propertyAccess.ts, 79, 3))
>numIndex : Symbol(numIndex, Decl(propertyAccess.ts, 10, 3))
>someObject : Symbol(someObject, Decl(propertyAccess.ts, 29, 3))
// Bracket notation property access using string value on type with string index signature and no numeric index signature
var mm = strIndex['N'];
>mm : Symbol(mm, Decl(propertyAccess.ts, 82, 3), Decl(propertyAccess.ts, 83, 3))
>strIndex : Symbol(strIndex, Decl(propertyAccess.ts, 11, 3))
var mm: Compass;
>mm : Symbol(mm, Decl(propertyAccess.ts, 82, 3), Decl(propertyAccess.ts, 83, 3))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
var mm2 = strIndex['zzz'];
>mm2 : Symbol(mm2, Decl(propertyAccess.ts, 84, 3), Decl(propertyAccess.ts, 85, 3))
>strIndex : Symbol(strIndex, Decl(propertyAccess.ts, 11, 3))
var mm2: Compass;
>mm2 : Symbol(mm2, Decl(propertyAccess.ts, 84, 3), Decl(propertyAccess.ts, 85, 3))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
// Bracket notation property access using numeric value on type with string index signature and no numeric index signature
var nn = strIndex[10];
>nn : Symbol(nn, Decl(propertyAccess.ts, 88, 3), Decl(propertyAccess.ts, 89, 3))
>strIndex : Symbol(strIndex, Decl(propertyAccess.ts, 11, 3))
var nn: Compass;
>nn : Symbol(nn, Decl(propertyAccess.ts, 88, 3), Decl(propertyAccess.ts, 89, 3))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
// Bracket notation property access using enum value on type with string index signature and no numeric index signature
var oo = strIndex[Compass.East];
>oo : Symbol(oo, Decl(propertyAccess.ts, 92, 3), Decl(propertyAccess.ts, 93, 3))
>strIndex : Symbol(strIndex, Decl(propertyAccess.ts, 11, 3))
>Compass.East : Symbol(Compass.East, Decl(propertyAccess.ts, 7, 17))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
>East : Symbol(Compass.East, Decl(propertyAccess.ts, 7, 17))
var oo: Compass;
>oo : Symbol(oo, Decl(propertyAccess.ts, 92, 3), Decl(propertyAccess.ts, 93, 3))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
// Bracket notation property access using value of type 'any' on type with string index signature and no numeric index signature
var pp = strIndex[<any>null];
>pp : Symbol(pp, Decl(propertyAccess.ts, 96, 3), Decl(propertyAccess.ts, 97, 3))
>strIndex : Symbol(strIndex, Decl(propertyAccess.ts, 11, 3))
var pp: Compass;
>pp : Symbol(pp, Decl(propertyAccess.ts, 96, 3), Decl(propertyAccess.ts, 97, 3))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
// Bracket notation property access using numeric value on type with no index signatures
var qq = noIndex[123];
>qq : Symbol(qq, Decl(propertyAccess.ts, 100, 3), Decl(propertyAccess.ts, 101, 3))
>noIndex : Symbol(noIndex, Decl(propertyAccess.ts, 16, 6))
var qq: any;
>qq : Symbol(qq, Decl(propertyAccess.ts, 100, 3), Decl(propertyAccess.ts, 101, 3))
// Bracket notation property access using string value on type with no index signatures
var rr = noIndex['zzzz'];
>rr : Symbol(rr, Decl(propertyAccess.ts, 104, 3), Decl(propertyAccess.ts, 105, 3))
>noIndex : Symbol(noIndex, Decl(propertyAccess.ts, 16, 6))
var rr: any;
>rr : Symbol(rr, Decl(propertyAccess.ts, 104, 3), Decl(propertyAccess.ts, 105, 3))
// Bracket notation property access using enum value on type with no index signatures
var ss = noIndex[Compass.South];
>ss : Symbol(ss, Decl(propertyAccess.ts, 108, 3), Decl(propertyAccess.ts, 109, 3))
>noIndex : Symbol(noIndex, Decl(propertyAccess.ts, 16, 6))
>Compass.South : Symbol(Compass.South, Decl(propertyAccess.ts, 7, 10))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
>South : Symbol(Compass.South, Decl(propertyAccess.ts, 7, 10))
var ss: any;
>ss : Symbol(ss, Decl(propertyAccess.ts, 108, 3), Decl(propertyAccess.ts, 109, 3))
// Bracket notation property access using value of type 'any' on type with no index signatures
var tt = noIndex[<any>null];
>tt : Symbol(tt, Decl(propertyAccess.ts, 112, 3), Decl(propertyAccess.ts, 113, 3))
>noIndex : Symbol(noIndex, Decl(propertyAccess.ts, 16, 6))
var tt: any;
>tt : Symbol(tt, Decl(propertyAccess.ts, 112, 3), Decl(propertyAccess.ts, 113, 3))
// Bracket notation property access using values of other types on type with no index signatures
var uu = noIndex[someObject]; // Error
>uu : Symbol(uu, Decl(propertyAccess.ts, 116, 3))
>noIndex : Symbol(noIndex, Decl(propertyAccess.ts, 16, 6))
>someObject : Symbol(someObject, Decl(propertyAccess.ts, 29, 3))
// Bracket notation property access using numeric value on type with numeric index signature and string index signature
var vv = noIndex[32];
>vv : Symbol(vv, Decl(propertyAccess.ts, 119, 3), Decl(propertyAccess.ts, 120, 3))
>noIndex : Symbol(noIndex, Decl(propertyAccess.ts, 16, 6))
var vv: any;
>vv : Symbol(vv, Decl(propertyAccess.ts, 119, 3), Decl(propertyAccess.ts, 120, 3))
// Bracket notation property access using enum value on type with numeric index signature and string index signature
var ww = bothIndex[Compass.East];
>ww : Symbol(ww, Decl(propertyAccess.ts, 123, 3), Decl(propertyAccess.ts, 124, 3))
>bothIndex : Symbol(bothIndex, Decl(propertyAccess.ts, 12, 3))
>Compass.East : Symbol(Compass.East, Decl(propertyAccess.ts, 7, 17))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
>East : Symbol(Compass.East, Decl(propertyAccess.ts, 7, 17))
var ww: B;
>ww : Symbol(ww, Decl(propertyAccess.ts, 123, 3), Decl(propertyAccess.ts, 124, 3))
>B : Symbol(B, Decl(propertyAccess.ts, 2, 1))
// Bracket notation property access using value of type 'any' on type with numeric index signature and string index signature
var xx = bothIndex[<any>null];
>xx : Symbol(xx, Decl(propertyAccess.ts, 127, 3), Decl(propertyAccess.ts, 128, 3))
>bothIndex : Symbol(bothIndex, Decl(propertyAccess.ts, 12, 3))
var xx: B;
>xx : Symbol(xx, Decl(propertyAccess.ts, 127, 3), Decl(propertyAccess.ts, 128, 3))
>B : Symbol(B, Decl(propertyAccess.ts, 2, 1))
// Bracket notation property access using string value on type with numeric index signature and string index signature
var yy = bothIndex['foo'];
>yy : Symbol(yy, Decl(propertyAccess.ts, 131, 3), Decl(propertyAccess.ts, 132, 3))
>bothIndex : Symbol(bothIndex, Decl(propertyAccess.ts, 12, 3))
var yy: A;
>yy : Symbol(yy, Decl(propertyAccess.ts, 131, 3), Decl(propertyAccess.ts, 132, 3))
>A : Symbol(A, Decl(propertyAccess.ts, 0, 0))
// Bracket notation property access using numeric string value on type with numeric index signature and string index signature
var zz = bothIndex['1.0'];
>zz : Symbol(zz, Decl(propertyAccess.ts, 135, 3), Decl(propertyAccess.ts, 136, 3))
>bothIndex : Symbol(bothIndex, Decl(propertyAccess.ts, 12, 3))
var zz: A;
>zz : Symbol(zz, Decl(propertyAccess.ts, 135, 3), Decl(propertyAccess.ts, 136, 3))
>A : Symbol(A, Decl(propertyAccess.ts, 0, 0))
// Bracket notation property access using value of other type on type with numeric index signature and no string index signature and string index signature
var zzzz = bothIndex[someObject]; // Error
>zzzz : Symbol(zzzz, Decl(propertyAccess.ts, 139, 3))
>bothIndex : Symbol(bothIndex, Decl(propertyAccess.ts, 12, 3))
>someObject : Symbol(someObject, Decl(propertyAccess.ts, 29, 3))
var x1 = numIndex[stringOrNumber];
>x1 : Symbol(x1, Decl(propertyAccess.ts, 141, 3), Decl(propertyAccess.ts, 142, 3))
>numIndex : Symbol(numIndex, Decl(propertyAccess.ts, 10, 3))
>stringOrNumber : Symbol(stringOrNumber, Decl(propertyAccess.ts, 28, 3))
var x1: any;
>x1 : Symbol(x1, Decl(propertyAccess.ts, 141, 3), Decl(propertyAccess.ts, 142, 3))
var x2 = strIndex[stringOrNumber];
>x2 : Symbol(x2, Decl(propertyAccess.ts, 144, 3), Decl(propertyAccess.ts, 145, 3))
>strIndex : Symbol(strIndex, Decl(propertyAccess.ts, 11, 3))
>stringOrNumber : Symbol(stringOrNumber, Decl(propertyAccess.ts, 28, 3))
var x2: Compass;
>x2 : Symbol(x2, Decl(propertyAccess.ts, 144, 3), Decl(propertyAccess.ts, 145, 3))
>Compass : Symbol(Compass, Decl(propertyAccess.ts, 5, 1))
var x3 = bothIndex[stringOrNumber];
>x3 : Symbol(x3, Decl(propertyAccess.ts, 147, 3), Decl(propertyAccess.ts, 148, 3))
>bothIndex : Symbol(bothIndex, Decl(propertyAccess.ts, 12, 3))
>stringOrNumber : Symbol(stringOrNumber, Decl(propertyAccess.ts, 28, 3))
var x3: A;
>x3 : Symbol(x3, Decl(propertyAccess.ts, 147, 3), Decl(propertyAccess.ts, 148, 3))
>A : Symbol(A, Decl(propertyAccess.ts, 0, 0))
|