76 lines
4.2 KiB
Text
76 lines
4.2 KiB
Text
=== tests/cases/compiler/contextualSignatureInstantiation3.ts ===
|
|
function map<T, U>(items: T[], f: (x: T) => U): U[]{
|
|
>map : Symbol(map, Decl(contextualSignatureInstantiation3.ts, 0, 0))
|
|
>T : Symbol(T, Decl(contextualSignatureInstantiation3.ts, 0, 13))
|
|
>U : Symbol(U, Decl(contextualSignatureInstantiation3.ts, 0, 15))
|
|
>items : Symbol(items, Decl(contextualSignatureInstantiation3.ts, 0, 19))
|
|
>T : Symbol(T, Decl(contextualSignatureInstantiation3.ts, 0, 13))
|
|
>f : Symbol(f, Decl(contextualSignatureInstantiation3.ts, 0, 30))
|
|
>x : Symbol(x, Decl(contextualSignatureInstantiation3.ts, 0, 35))
|
|
>T : Symbol(T, Decl(contextualSignatureInstantiation3.ts, 0, 13))
|
|
>U : Symbol(U, Decl(contextualSignatureInstantiation3.ts, 0, 15))
|
|
>U : Symbol(U, Decl(contextualSignatureInstantiation3.ts, 0, 15))
|
|
|
|
return items.map(f);
|
|
>items.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
|
|
>items : Symbol(items, Decl(contextualSignatureInstantiation3.ts, 0, 19))
|
|
>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
|
|
>f : Symbol(f, Decl(contextualSignatureInstantiation3.ts, 0, 30))
|
|
}
|
|
|
|
function identity<T>(x: T) {
|
|
>identity : Symbol(identity, Decl(contextualSignatureInstantiation3.ts, 2, 1))
|
|
>T : Symbol(T, Decl(contextualSignatureInstantiation3.ts, 4, 18))
|
|
>x : Symbol(x, Decl(contextualSignatureInstantiation3.ts, 4, 21))
|
|
>T : Symbol(T, Decl(contextualSignatureInstantiation3.ts, 4, 18))
|
|
|
|
return x;
|
|
>x : Symbol(x, Decl(contextualSignatureInstantiation3.ts, 4, 21))
|
|
}
|
|
|
|
function singleton<T>(x: T) {
|
|
>singleton : Symbol(singleton, Decl(contextualSignatureInstantiation3.ts, 6, 1))
|
|
>T : Symbol(T, Decl(contextualSignatureInstantiation3.ts, 8, 19))
|
|
>x : Symbol(x, Decl(contextualSignatureInstantiation3.ts, 8, 22))
|
|
>T : Symbol(T, Decl(contextualSignatureInstantiation3.ts, 8, 19))
|
|
|
|
return [x];
|
|
>x : Symbol(x, Decl(contextualSignatureInstantiation3.ts, 8, 22))
|
|
}
|
|
|
|
var xs = [1, 2, 3];
|
|
>xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3))
|
|
|
|
// Have compiler check that we get the correct types
|
|
var v1: number[];
|
|
>v1 : Symbol(v1, Decl(contextualSignatureInstantiation3.ts, 15, 3), Decl(contextualSignatureInstantiation3.ts, 16, 3), Decl(contextualSignatureInstantiation3.ts, 17, 3))
|
|
|
|
var v1 = xs.map(identity); // Error if not number[]
|
|
>v1 : Symbol(v1, Decl(contextualSignatureInstantiation3.ts, 15, 3), Decl(contextualSignatureInstantiation3.ts, 16, 3), Decl(contextualSignatureInstantiation3.ts, 17, 3))
|
|
>xs.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
|
|
>xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3))
|
|
>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
|
|
>identity : Symbol(identity, Decl(contextualSignatureInstantiation3.ts, 2, 1))
|
|
|
|
var v1 = map(xs, identity); // Error if not number[]
|
|
>v1 : Symbol(v1, Decl(contextualSignatureInstantiation3.ts, 15, 3), Decl(contextualSignatureInstantiation3.ts, 16, 3), Decl(contextualSignatureInstantiation3.ts, 17, 3))
|
|
>map : Symbol(map, Decl(contextualSignatureInstantiation3.ts, 0, 0))
|
|
>xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3))
|
|
>identity : Symbol(identity, Decl(contextualSignatureInstantiation3.ts, 2, 1))
|
|
|
|
var v2: number[][];
|
|
>v2 : Symbol(v2, Decl(contextualSignatureInstantiation3.ts, 19, 3), Decl(contextualSignatureInstantiation3.ts, 20, 3), Decl(contextualSignatureInstantiation3.ts, 21, 3))
|
|
|
|
var v2 = xs.map(singleton); // Error if not number[][]
|
|
>v2 : Symbol(v2, Decl(contextualSignatureInstantiation3.ts, 19, 3), Decl(contextualSignatureInstantiation3.ts, 20, 3), Decl(contextualSignatureInstantiation3.ts, 21, 3))
|
|
>xs.map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
|
|
>xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3))
|
|
>map : Symbol(Array.map, Decl(lib.d.ts, 1115, 92))
|
|
>singleton : Symbol(singleton, Decl(contextualSignatureInstantiation3.ts, 6, 1))
|
|
|
|
var v2 = map(xs, singleton); // Error if not number[][]
|
|
>v2 : Symbol(v2, Decl(contextualSignatureInstantiation3.ts, 19, 3), Decl(contextualSignatureInstantiation3.ts, 20, 3), Decl(contextualSignatureInstantiation3.ts, 21, 3))
|
|
>map : Symbol(map, Decl(contextualSignatureInstantiation3.ts, 0, 0))
|
|
>xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3))
|
|
>singleton : Symbol(singleton, Decl(contextualSignatureInstantiation3.ts, 6, 1))
|
|
|