2014-12-09 23:08:44 +01:00
|
|
|
=== tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts ===
|
|
|
|
|
|
|
|
enum MyEmusEnum {
|
2015-04-13 23:01:57 +02:00
|
|
|
>MyEmusEnum : MyEmusEnum, Symbol(MyEmusEnum, Decl(noImplicitAnyIndexingSuppressed.ts, 0, 0))
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
emu
|
2015-04-13 23:01:57 +02:00
|
|
|
>emu : MyEmusEnum, Symbol(MyEmusEnum.emu, Decl(noImplicitAnyIndexingSuppressed.ts, 1, 17))
|
2014-12-09 23:08:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Should be okay; should be a string.
|
|
|
|
var strRepresentation1 = MyEmusEnum[0]
|
2015-04-13 23:01:57 +02:00
|
|
|
>strRepresentation1 : string, Symbol(strRepresentation1, Decl(noImplicitAnyIndexingSuppressed.ts, 6, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>MyEmusEnum[0] : string
|
2015-04-13 23:01:57 +02:00
|
|
|
>MyEmusEnum : typeof MyEmusEnum, Symbol(MyEmusEnum, Decl(noImplicitAnyIndexingSuppressed.ts, 0, 0))
|
2015-04-13 21:36:11 +02:00
|
|
|
>0 : number
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
// Should be okay; should be a string.
|
|
|
|
var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu]
|
2015-04-13 23:01:57 +02:00
|
|
|
>strRepresentation2 : string, Symbol(strRepresentation2, Decl(noImplicitAnyIndexingSuppressed.ts, 9, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>MyEmusEnum[MyEmusEnum.emu] : string
|
2015-04-13 23:01:57 +02:00
|
|
|
>MyEmusEnum : typeof MyEmusEnum, Symbol(MyEmusEnum, Decl(noImplicitAnyIndexingSuppressed.ts, 0, 0))
|
|
|
|
>MyEmusEnum.emu : MyEmusEnum, Symbol(MyEmusEnum.emu, Decl(noImplicitAnyIndexingSuppressed.ts, 1, 17))
|
|
|
|
>MyEmusEnum : typeof MyEmusEnum, Symbol(MyEmusEnum, Decl(noImplicitAnyIndexingSuppressed.ts, 0, 0))
|
|
|
|
>emu : MyEmusEnum, Symbol(MyEmusEnum.emu, Decl(noImplicitAnyIndexingSuppressed.ts, 1, 17))
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
// Should be okay, as we suppress implicit 'any' property access checks
|
|
|
|
var strRepresentation3 = MyEmusEnum["monehh"];
|
2015-04-13 23:01:57 +02:00
|
|
|
>strRepresentation3 : any, Symbol(strRepresentation3, Decl(noImplicitAnyIndexingSuppressed.ts, 12, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>MyEmusEnum["monehh"] : any
|
2015-04-13 23:01:57 +02:00
|
|
|
>MyEmusEnum : typeof MyEmusEnum, Symbol(MyEmusEnum, Decl(noImplicitAnyIndexingSuppressed.ts, 0, 0))
|
2015-04-13 21:36:11 +02:00
|
|
|
>"monehh" : string
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
// Should be okay; should be a MyEmusEnum
|
|
|
|
var strRepresentation4 = MyEmusEnum["emu"];
|
2015-04-13 23:01:57 +02:00
|
|
|
>strRepresentation4 : MyEmusEnum, Symbol(strRepresentation4, Decl(noImplicitAnyIndexingSuppressed.ts, 15, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>MyEmusEnum["emu"] : MyEmusEnum
|
2015-04-13 23:01:57 +02:00
|
|
|
>MyEmusEnum : typeof MyEmusEnum, Symbol(MyEmusEnum, Decl(noImplicitAnyIndexingSuppressed.ts, 0, 0))
|
|
|
|
>"emu" : string, Symbol(MyEmusEnum.emu, Decl(noImplicitAnyIndexingSuppressed.ts, 1, 17))
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
// Should be okay, as we suppress implicit 'any' property access checks
|
|
|
|
var x = {}["hi"];
|
2015-04-13 23:01:57 +02:00
|
|
|
>x : any, Symbol(x, Decl(noImplicitAnyIndexingSuppressed.ts, 19, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>{}["hi"] : any
|
|
|
|
>{} : {}
|
2015-04-13 21:36:11 +02:00
|
|
|
>"hi" : string
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
// Should be okay, as we suppress implicit 'any' property access checks
|
|
|
|
var y = {}[10];
|
2015-04-13 23:01:57 +02:00
|
|
|
>y : any, Symbol(y, Decl(noImplicitAnyIndexingSuppressed.ts, 22, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>{}[10] : any
|
|
|
|
>{} : {}
|
2015-04-13 21:36:11 +02:00
|
|
|
>10 : number
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
var hi: any = "hi";
|
2015-04-13 23:01:57 +02:00
|
|
|
>hi : any, Symbol(hi, Decl(noImplicitAnyIndexingSuppressed.ts, 24, 3))
|
2015-04-13 21:36:11 +02:00
|
|
|
>"hi" : string
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
var emptyObj = {};
|
2015-04-13 23:01:57 +02:00
|
|
|
>emptyObj : {}, Symbol(emptyObj, Decl(noImplicitAnyIndexingSuppressed.ts, 26, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>{} : {}
|
|
|
|
|
|
|
|
// Should be okay, as we suppress implicit 'any' property access checks
|
|
|
|
var z1 = emptyObj[hi];
|
2015-04-13 23:01:57 +02:00
|
|
|
>z1 : any, Symbol(z1, Decl(noImplicitAnyIndexingSuppressed.ts, 29, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>emptyObj[hi] : any
|
2015-04-13 23:01:57 +02:00
|
|
|
>emptyObj : {}, Symbol(emptyObj, Decl(noImplicitAnyIndexingSuppressed.ts, 26, 3))
|
|
|
|
>hi : any, Symbol(hi, Decl(noImplicitAnyIndexingSuppressed.ts, 24, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
var z2 = (<any>emptyObj)[hi];
|
2015-04-13 23:01:57 +02:00
|
|
|
>z2 : any, Symbol(z2, Decl(noImplicitAnyIndexingSuppressed.ts, 30, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>(<any>emptyObj)[hi] : any
|
|
|
|
>(<any>emptyObj) : any
|
|
|
|
><any>emptyObj : any
|
2015-04-13 23:01:57 +02:00
|
|
|
>emptyObj : {}, Symbol(emptyObj, Decl(noImplicitAnyIndexingSuppressed.ts, 26, 3))
|
|
|
|
>hi : any, Symbol(hi, Decl(noImplicitAnyIndexingSuppressed.ts, 24, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
interface MyMap<T> {
|
2015-04-13 23:01:57 +02:00
|
|
|
>MyMap : MyMap<T>, Symbol(MyMap, Decl(noImplicitAnyIndexingSuppressed.ts, 30, 29))
|
|
|
|
>T : T, Symbol(T, Decl(noImplicitAnyIndexingSuppressed.ts, 32, 16))
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
[key: string]: T;
|
2015-04-13 23:01:57 +02:00
|
|
|
>key : string, Symbol(key, Decl(noImplicitAnyIndexingSuppressed.ts, 33, 5))
|
|
|
|
>T : T, Symbol(T, Decl(noImplicitAnyIndexingSuppressed.ts, 32, 16))
|
2014-12-09 23:08:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var m: MyMap<number> = {
|
2015-04-13 23:01:57 +02:00
|
|
|
>m : MyMap<number>, Symbol(m, Decl(noImplicitAnyIndexingSuppressed.ts, 36, 3))
|
|
|
|
>MyMap : MyMap<T>, Symbol(MyMap, Decl(noImplicitAnyIndexingSuppressed.ts, 30, 29))
|
2014-12-09 23:08:44 +01:00
|
|
|
>{ "0": 0, "1": 1, "2": 2, "Okay that's enough for today.": NaN} : { [x: string]: number; "0": number; "1": number; "2": number; "Okay that's enough for today.": number; }
|
|
|
|
|
|
|
|
"0": 0,
|
2015-04-13 21:36:11 +02:00
|
|
|
>0 : number
|
|
|
|
|
2014-12-09 23:08:44 +01:00
|
|
|
"1": 1,
|
2015-04-13 21:36:11 +02:00
|
|
|
>1 : number
|
|
|
|
|
2014-12-09 23:08:44 +01:00
|
|
|
"2": 2,
|
2015-04-13 21:36:11 +02:00
|
|
|
>2 : number
|
|
|
|
|
2014-12-09 23:08:44 +01:00
|
|
|
"Okay that's enough for today.": NaN
|
2015-04-13 23:01:57 +02:00
|
|
|
>NaN : number, Symbol(NaN, Decl(lib.d.ts, 21, 11))
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var mResult1 = m[MyEmusEnum.emu];
|
2015-04-13 23:01:57 +02:00
|
|
|
>mResult1 : number, Symbol(mResult1, Decl(noImplicitAnyIndexingSuppressed.ts, 43, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>m[MyEmusEnum.emu] : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>m : MyMap<number>, Symbol(m, Decl(noImplicitAnyIndexingSuppressed.ts, 36, 3))
|
|
|
|
>MyEmusEnum.emu : MyEmusEnum, Symbol(MyEmusEnum.emu, Decl(noImplicitAnyIndexingSuppressed.ts, 1, 17))
|
|
|
|
>MyEmusEnum : typeof MyEmusEnum, Symbol(MyEmusEnum, Decl(noImplicitAnyIndexingSuppressed.ts, 0, 0))
|
|
|
|
>emu : MyEmusEnum, Symbol(MyEmusEnum.emu, Decl(noImplicitAnyIndexingSuppressed.ts, 1, 17))
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
var mResult2 = m[MyEmusEnum[MyEmusEnum.emu]];
|
2015-04-13 23:01:57 +02:00
|
|
|
>mResult2 : number, Symbol(mResult2, Decl(noImplicitAnyIndexingSuppressed.ts, 44, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>m[MyEmusEnum[MyEmusEnum.emu]] : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>m : MyMap<number>, Symbol(m, Decl(noImplicitAnyIndexingSuppressed.ts, 36, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>MyEmusEnum[MyEmusEnum.emu] : string
|
2015-04-13 23:01:57 +02:00
|
|
|
>MyEmusEnum : typeof MyEmusEnum, Symbol(MyEmusEnum, Decl(noImplicitAnyIndexingSuppressed.ts, 0, 0))
|
|
|
|
>MyEmusEnum.emu : MyEmusEnum, Symbol(MyEmusEnum.emu, Decl(noImplicitAnyIndexingSuppressed.ts, 1, 17))
|
|
|
|
>MyEmusEnum : typeof MyEmusEnum, Symbol(MyEmusEnum, Decl(noImplicitAnyIndexingSuppressed.ts, 0, 0))
|
|
|
|
>emu : MyEmusEnum, Symbol(MyEmusEnum.emu, Decl(noImplicitAnyIndexingSuppressed.ts, 1, 17))
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
var mResult3 = m[hi];
|
2015-04-13 23:01:57 +02:00
|
|
|
>mResult3 : number, Symbol(mResult3, Decl(noImplicitAnyIndexingSuppressed.ts, 45, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
>m[hi] : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>m : MyMap<number>, Symbol(m, Decl(noImplicitAnyIndexingSuppressed.ts, 36, 3))
|
|
|
|
>hi : any, Symbol(hi, Decl(noImplicitAnyIndexingSuppressed.ts, 24, 3))
|
2014-12-09 23:08:44 +01:00
|
|
|
|
|
|
|
|