File: genericReversingTypeParameters.types

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (55 lines) | stat: -rw-r--r-- 1,186 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
55
=== tests/cases/compiler/genericReversingTypeParameters.ts ===
class BiMap<K, V> {
>BiMap : BiMap<K, V>
>K : K
>V : V

    private inverseBiMap: BiMap<V, K>;
>inverseBiMap : BiMap<V, K>
>BiMap : BiMap<K, V>
>V : V
>K : K

    public get(key: K): V { return null; }
>get : (key: K) => V
>key : K
>K : K
>V : V
>null : null

    public inverse(): BiMap<V, K> { return null; }
>inverse : () => BiMap<V, K>
>BiMap : BiMap<K, V>
>V : V
>K : K
>null : null
}

var b = new BiMap<string, number>();
>b : BiMap<string, number>
>new BiMap<string, number>() : BiMap<string, number>
>BiMap : typeof BiMap

var r1 = b.get(''); 
>r1 : number
>b.get('') : number
>b.get : (key: string) => number
>b : BiMap<string, number>
>get : (key: string) => number
>'' : ""

var i = b.inverse(); // used to get the type wrong here.
>i : BiMap<number, string>
>b.inverse() : BiMap<number, string>
>b.inverse : () => BiMap<number, string>
>b : BiMap<string, number>
>inverse : () => BiMap<number, string>

var r2b = i.get(1); 
>r2b : string
>i.get(1) : string
>i.get : (key: number) => string
>i : BiMap<number, string>
>get : (key: number) => string
>1 : 1