Adding test

This commit is contained in:
Anders Hejlsberg
2015-12-10 13:54:58 -08:00
parent 9810ddf326
commit 3055445d27
4 changed files with 89 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
//// [typeParameterConstraintInstantiation.ts]
// Check that type parameter constraints are properly instantiated
interface Mapper<T> {
map<U extends T, V extends U[]>(f: (item: T) => U): V;
}
var m: Mapper<string>;
var a = m.map((x: string) => x); // string[]
//// [typeParameterConstraintInstantiation.js]
// Check that type parameter constraints are properly instantiated
var m;
var a = m.map(function (x) { return x; }); // string[]

View File

@@ -0,0 +1,32 @@
=== tests/cases/compiler/typeParameterConstraintInstantiation.ts ===
// Check that type parameter constraints are properly instantiated
interface Mapper<T> {
>Mapper : Symbol(Mapper, Decl(typeParameterConstraintInstantiation.ts, 0, 0))
>T : Symbol(T, Decl(typeParameterConstraintInstantiation.ts, 2, 17))
map<U extends T, V extends U[]>(f: (item: T) => U): V;
>map : Symbol(map, Decl(typeParameterConstraintInstantiation.ts, 2, 21))
>U : Symbol(U, Decl(typeParameterConstraintInstantiation.ts, 3, 8))
>T : Symbol(T, Decl(typeParameterConstraintInstantiation.ts, 2, 17))
>V : Symbol(V, Decl(typeParameterConstraintInstantiation.ts, 3, 20))
>U : Symbol(U, Decl(typeParameterConstraintInstantiation.ts, 3, 8))
>f : Symbol(f, Decl(typeParameterConstraintInstantiation.ts, 3, 36))
>item : Symbol(item, Decl(typeParameterConstraintInstantiation.ts, 3, 40))
>T : Symbol(T, Decl(typeParameterConstraintInstantiation.ts, 2, 17))
>U : Symbol(U, Decl(typeParameterConstraintInstantiation.ts, 3, 8))
>V : Symbol(V, Decl(typeParameterConstraintInstantiation.ts, 3, 20))
}
var m: Mapper<string>;
>m : Symbol(m, Decl(typeParameterConstraintInstantiation.ts, 6, 3))
>Mapper : Symbol(Mapper, Decl(typeParameterConstraintInstantiation.ts, 0, 0))
var a = m.map((x: string) => x); // string[]
>a : Symbol(a, Decl(typeParameterConstraintInstantiation.ts, 7, 3))
>m.map : Symbol(Mapper.map, Decl(typeParameterConstraintInstantiation.ts, 2, 21))
>m : Symbol(m, Decl(typeParameterConstraintInstantiation.ts, 6, 3))
>map : Symbol(Mapper.map, Decl(typeParameterConstraintInstantiation.ts, 2, 21))
>x : Symbol(x, Decl(typeParameterConstraintInstantiation.ts, 7, 15))
>x : Symbol(x, Decl(typeParameterConstraintInstantiation.ts, 7, 15))

View File

@@ -0,0 +1,34 @@
=== tests/cases/compiler/typeParameterConstraintInstantiation.ts ===
// Check that type parameter constraints are properly instantiated
interface Mapper<T> {
>Mapper : Mapper<T>
>T : T
map<U extends T, V extends U[]>(f: (item: T) => U): V;
>map : <U extends T, V extends U[]>(f: (item: T) => U) => V
>U : U
>T : T
>V : V
>U : U
>f : (item: T) => U
>item : T
>T : T
>U : U
>V : V
}
var m: Mapper<string>;
>m : Mapper<string>
>Mapper : Mapper<T>
var a = m.map((x: string) => x); // string[]
>a : string[]
>m.map((x: string) => x) : string[]
>m.map : <U extends string, V extends U[]>(f: (item: string) => U) => V
>m : Mapper<string>
>map : <U extends string, V extends U[]>(f: (item: string) => U) => V
>(x: string) => x : (x: string) => string
>x : string
>x : string

View File

@@ -0,0 +1,8 @@
// Check that type parameter constraints are properly instantiated
interface Mapper<T> {
map<U extends T, V extends U[]>(f: (item: T) => U): V;
}
var m: Mapper<string>;
var a = m.map((x: string) => x); // string[]