TypeScript/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types
2015-04-13 14:29:37 -07:00

131 lines
5.7 KiB
Plaintext

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