Skip to content

Commit 3055445

Browse files
committed
Adding test
1 parent 9810ddf commit 3055445

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//// [typeParameterConstraintInstantiation.ts]
2+
// Check that type parameter constraints are properly instantiated
3+
4+
interface Mapper<T> {
5+
map<U extends T, V extends U[]>(f: (item: T) => U): V;
6+
}
7+
8+
var m: Mapper<string>;
9+
var a = m.map((x: string) => x); // string[]
10+
11+
12+
//// [typeParameterConstraintInstantiation.js]
13+
// Check that type parameter constraints are properly instantiated
14+
var m;
15+
var a = m.map(function (x) { return x; }); // string[]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
=== tests/cases/compiler/typeParameterConstraintInstantiation.ts ===
2+
// Check that type parameter constraints are properly instantiated
3+
4+
interface Mapper<T> {
5+
>Mapper : Symbol(Mapper, Decl(typeParameterConstraintInstantiation.ts, 0, 0))
6+
>T : Symbol(T, Decl(typeParameterConstraintInstantiation.ts, 2, 17))
7+
8+
map<U extends T, V extends U[]>(f: (item: T) => U): V;
9+
>map : Symbol(map, Decl(typeParameterConstraintInstantiation.ts, 2, 21))
10+
>U : Symbol(U, Decl(typeParameterConstraintInstantiation.ts, 3, 8))
11+
>T : Symbol(T, Decl(typeParameterConstraintInstantiation.ts, 2, 17))
12+
>V : Symbol(V, Decl(typeParameterConstraintInstantiation.ts, 3, 20))
13+
>U : Symbol(U, Decl(typeParameterConstraintInstantiation.ts, 3, 8))
14+
>f : Symbol(f, Decl(typeParameterConstraintInstantiation.ts, 3, 36))
15+
>item : Symbol(item, Decl(typeParameterConstraintInstantiation.ts, 3, 40))
16+
>T : Symbol(T, Decl(typeParameterConstraintInstantiation.ts, 2, 17))
17+
>U : Symbol(U, Decl(typeParameterConstraintInstantiation.ts, 3, 8))
18+
>V : Symbol(V, Decl(typeParameterConstraintInstantiation.ts, 3, 20))
19+
}
20+
21+
var m: Mapper<string>;
22+
>m : Symbol(m, Decl(typeParameterConstraintInstantiation.ts, 6, 3))
23+
>Mapper : Symbol(Mapper, Decl(typeParameterConstraintInstantiation.ts, 0, 0))
24+
25+
var a = m.map((x: string) => x); // string[]
26+
>a : Symbol(a, Decl(typeParameterConstraintInstantiation.ts, 7, 3))
27+
>m.map : Symbol(Mapper.map, Decl(typeParameterConstraintInstantiation.ts, 2, 21))
28+
>m : Symbol(m, Decl(typeParameterConstraintInstantiation.ts, 6, 3))
29+
>map : Symbol(Mapper.map, Decl(typeParameterConstraintInstantiation.ts, 2, 21))
30+
>x : Symbol(x, Decl(typeParameterConstraintInstantiation.ts, 7, 15))
31+
>x : Symbol(x, Decl(typeParameterConstraintInstantiation.ts, 7, 15))
32+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
=== tests/cases/compiler/typeParameterConstraintInstantiation.ts ===
2+
// Check that type parameter constraints are properly instantiated
3+
4+
interface Mapper<T> {
5+
>Mapper : Mapper<T>
6+
>T : T
7+
8+
map<U extends T, V extends U[]>(f: (item: T) => U): V;
9+
>map : <U extends T, V extends U[]>(f: (item: T) => U) => V
10+
>U : U
11+
>T : T
12+
>V : V
13+
>U : U
14+
>f : (item: T) => U
15+
>item : T
16+
>T : T
17+
>U : U
18+
>V : V
19+
}
20+
21+
var m: Mapper<string>;
22+
>m : Mapper<string>
23+
>Mapper : Mapper<T>
24+
25+
var a = m.map((x: string) => x); // string[]
26+
>a : string[]
27+
>m.map((x: string) => x) : string[]
28+
>m.map : <U extends string, V extends U[]>(f: (item: string) => U) => V
29+
>m : Mapper<string>
30+
>map : <U extends string, V extends U[]>(f: (item: string) => U) => V
31+
>(x: string) => x : (x: string) => string
32+
>x : string
33+
>x : string
34+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Check that type parameter constraints are properly instantiated
2+
3+
interface Mapper<T> {
4+
map<U extends T, V extends U[]>(f: (item: T) => U): V;
5+
}
6+
7+
var m: Mapper<string>;
8+
var a = m.map((x: string) => x); // string[]

0 commit comments

Comments
 (0)