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
|
=== tests/cases/compiler/objectLiteralIndexers.ts ===
interface A {
x: number;
>x : number
}
interface B extends A {
y: string;
>y : string
}
var a: A;
>a : A
var b: B;
>b : B
var c: any;
>c : any
var o1: { [s: string]: A;[n: number]: B; } = { x: a, 0: b }; // string indexer is A, number indexer is B
>o1 : { [s: string]: A; [n: number]: B; }
>s : string
>n : number
>{ x: a, 0: b } : { x: A; 0: B; }
>x : A
>a : A
>0 : B
>b : B
o1 = { x: b, 0: c }; // both indexers are any
>o1 = { x: b, 0: c } : { x: B; 0: any; }
>o1 : { [s: string]: A; [n: number]: B; }
>{ x: b, 0: c } : { x: B; 0: any; }
>x : B
>b : B
>0 : any
>c : any
o1 = { x: c, 0: b }; // string indexer is any, number indexer is B
>o1 = { x: c, 0: b } : { x: any; 0: B; }
>o1 : { [s: string]: A; [n: number]: B; }
>{ x: c, 0: b } : { x: any; 0: B; }
>x : any
>c : any
>0 : B
>b : B
|