File: objectLiteralIndexers.types

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (48 lines) | stat: -rw-r--r-- 909 bytes parent folder | download | duplicates (5)
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