2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/objectLiteralIndexers.ts ===
|
|
|
|
interface A {
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
x: number;
|
|
|
|
>x : number
|
|
|
|
}
|
|
|
|
|
|
|
|
interface B extends A {
|
|
|
|
>B : B
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
y: string;
|
|
|
|
>y : string
|
|
|
|
}
|
|
|
|
|
|
|
|
var a: A;
|
|
|
|
>a : A
|
|
|
|
>A : A
|
|
|
|
|
|
|
|
var b: B;
|
|
|
|
>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
|
2014-12-06 01:58:49 +01:00
|
|
|
>o1 : { [s: string]: A; [n: number]: B; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>s : string
|
|
|
|
>A : A
|
|
|
|
>n : number
|
|
|
|
>B : B
|
|
|
|
>{ x: a, 0: b } : { [x: string]: A; [x: number]: B; 0: B; x: A; }
|
|
|
|
>x : A
|
2014-08-25 19:36:12 +02:00
|
|
|
>a : A
|
|
|
|
>b : B
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
o1 = { x: b, 0: c }; // both indexers are any
|
|
|
|
>o1 = { x: b, 0: c } : { [x: string]: any; [x: number]: any; 0: any; x: B; }
|
2014-12-06 01:58:49 +01:00
|
|
|
>o1 : { [s: string]: A; [n: number]: B; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>{ x: b, 0: c } : { [x: string]: any; [x: number]: any; 0: any; x: B; }
|
|
|
|
>x : B
|
2014-08-25 19:36:12 +02:00
|
|
|
>b : B
|
|
|
|
>c : any
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
o1 = { x: c, 0: b }; // string indexer is any, number indexer is B
|
|
|
|
>o1 = { x: c, 0: b } : { [x: string]: any; [x: number]: B; 0: B; x: any; }
|
2014-12-06 01:58:49 +01:00
|
|
|
>o1 : { [s: string]: A; [n: number]: B; }
|
2014-08-15 23:33:16 +02:00
|
|
|
>{ x: c, 0: b } : { [x: string]: any; [x: number]: B; 0: B; x: any; }
|
|
|
|
>x : any
|
2014-08-25 19:36:12 +02:00
|
|
|
>c : any
|
|
|
|
>b : B
|
2014-08-15 23:33:16 +02:00
|
|
|
|