mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-09 07:55:10 -05:00
Adding test
This commit is contained in:
@@ -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[]
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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[]
|
||||
Reference in New Issue
Block a user