File: objectLiteralIndexers.types

package info (click to toggle)
node-typescript 2.1.5-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 203,960 kB
  • sloc: sh: 11; makefile: 5
file content (54 lines) | stat: -rw-r--r-- 943 bytes parent folder | download | duplicates (2)
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
49
50
51
52
53
54
=== 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 } : { 0: B; x: A; }
>x : A
>a : A
>b : B

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