2014-08-15 23:33:16 +02:00
|
|
|
=== 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>
|
2014-08-19 04:56:03 +02:00
|
|
|
>BiMap : BiMap<K, V>
|
2014-08-15 23:33:16 +02:00
|
|
|
>V : V
|
|
|
|
>K : K
|
|
|
|
|
|
|
|
public get(key: K): V { return null; }
|
|
|
|
>get : (key: K) => V
|
|
|
|
>key : K
|
|
|
|
>K : K
|
|
|
|
>V : V
|
|
|
|
|
|
|
|
public inverse(): BiMap<V, K> { return null; }
|
|
|
|
>inverse : () => BiMap<V, K>
|
2014-08-19 04:56:03 +02:00
|
|
|
>BiMap : BiMap<K, V>
|
2014-08-15 23:33:16 +02:00
|
|
|
>V : V
|
|
|
|
>K : K
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|