TypeScript/tests/baselines/reference/objectLiteralIndexers.types

55 lines
1.1 KiB
Plaintext
Raw Normal View History

2014-08-15 23:33:16 +02:00
=== tests/cases/compiler/objectLiteralIndexers.ts ===
interface A {
>A : A
2014-08-15 23:33:16 +02:00
x: number;
>x : number
2014-08-15 23:33:16 +02:00
}
interface B extends A {
>B : B
>A : A
2014-08-15 23:33:16 +02:00
y: string;
>y : string
2014-08-15 23:33:16 +02:00
}
var a: A;
>a : A
>A : A
2014-08-15 23:33:16 +02:00
var b: B;
>b : B
>B : B
2014-08-15 23:33:16 +02:00
var c: any;
>c : any
2014-08-15 23:33:16 +02:00
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
>A : A
>n : number
>B : B
2014-08-15 23:33:16 +02:00
>{ x: a, 0: b } : { [x: string]: A; [x: number]: B; 0: B; x: A; }
>x : A
>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; }
>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
>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; }
>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
>c : any
>b : B
2014-08-15 23:33:16 +02:00