TypeScript/tests/baselines/reference/objectLiteralIndexers.types
2015-04-15 16:44:20 -07:00

55 lines
1.1 KiB
Plaintext

=== 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
>o1 : { [s: string]: A; [n: number]: B; }
>s : string
>A : A
>n : number
>B : B
>{ x: a, 0: b } : { [x: string]: A; [x: number]: B; 0: B; x: A; }
>x : A
>a : A
>b : B
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; }
>{ x: b, 0: c } : { [x: string]: any; [x: number]: any; 0: any; x: B; }
>x : B
>b : B
>c : any
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; }
>{ x: c, 0: b } : { [x: string]: any; [x: number]: B; 0: B; x: any; }
>x : any
>c : any
>b : B