mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 10:58:20 -05:00
Accept new baselines
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
tests/cases/compiler/inferFromGenericFunctionReturnTypes1.ts(68,16): error TS2339: Property 'toUpperCase' does not exist on type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/inferFromGenericFunctionReturnTypes1.ts (1 errors) ====
|
||||
// Repro from #15680
|
||||
|
||||
// This is a contrived class. We could do the same thing with Observables, etc.
|
||||
class SetOf<A> {
|
||||
_store: A[];
|
||||
|
||||
add(a: A) {
|
||||
this._store.push(a);
|
||||
}
|
||||
|
||||
transform<B>(transformer: (a: SetOf<A>) => SetOf<B>): SetOf<B> {
|
||||
return transformer(this);
|
||||
}
|
||||
|
||||
forEach(fn: (a: A, index: number) => void) {
|
||||
this._store.forEach((a, i) => fn(a, i));
|
||||
}
|
||||
}
|
||||
|
||||
function compose<A, B, C, D, E>(
|
||||
fnA: (a: SetOf<A>) => SetOf<B>,
|
||||
fnB: (b: SetOf<B>) => SetOf<C>,
|
||||
fnC: (c: SetOf<C>) => SetOf<D>,
|
||||
fnD: (c: SetOf<D>) => SetOf<E>,
|
||||
):(x: SetOf<A>) => SetOf<E>;
|
||||
/* ... etc ... */
|
||||
function compose<T>(...fns: ((x: T) => T)[]): (x: T) => T {
|
||||
return (x: T) => fns.reduce((prev, fn) => fn(prev), x);
|
||||
}
|
||||
|
||||
function map<A, B>(fn: (a: A) => B): (s: SetOf<A>) => SetOf<B> {
|
||||
return (a: SetOf<A>) => {
|
||||
const b: SetOf<B> = new SetOf();
|
||||
a.forEach(x => b.add(fn(x)));
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
function filter<A>(predicate: (a: A) => boolean): (s: SetOf<A>) => SetOf<A> {
|
||||
return (a: SetOf<A>) => {
|
||||
const result = new SetOf<A>();
|
||||
a.forEach(x => {
|
||||
if (predicate(x)) result.add(x);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
const testSet = new SetOf<number>();
|
||||
testSet.add(1);
|
||||
testSet.add(2);
|
||||
testSet.add(3);
|
||||
|
||||
testSet.transform(
|
||||
compose(
|
||||
filter(x => x % 1 === 0),
|
||||
map(x => x + x),
|
||||
map(x => x + '!!!'),
|
||||
map(x => x.toUpperCase())
|
||||
)
|
||||
)
|
||||
|
||||
testSet.transform(
|
||||
compose(
|
||||
filter(x => x % 1 === 0),
|
||||
map(x => x + x),
|
||||
map(x => 123), // Whoops a bug
|
||||
map(x => x.toUpperCase()) // causes an error!
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'toUpperCase' does not exist on type 'number'.
|
||||
)
|
||||
)
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
//// [inferFromGenericFunctionReturnTypes1.ts]
|
||||
// Repro from #15680
|
||||
|
||||
// This is a contrived class. We could do the same thing with Observables, etc.
|
||||
class SetOf<A> {
|
||||
_store: A[];
|
||||
|
||||
add(a: A) {
|
||||
this._store.push(a);
|
||||
}
|
||||
|
||||
transform<B>(transformer: (a: SetOf<A>) => SetOf<B>): SetOf<B> {
|
||||
return transformer(this);
|
||||
}
|
||||
|
||||
forEach(fn: (a: A, index: number) => void) {
|
||||
this._store.forEach((a, i) => fn(a, i));
|
||||
}
|
||||
}
|
||||
|
||||
function compose<A, B, C, D, E>(
|
||||
fnA: (a: SetOf<A>) => SetOf<B>,
|
||||
fnB: (b: SetOf<B>) => SetOf<C>,
|
||||
fnC: (c: SetOf<C>) => SetOf<D>,
|
||||
fnD: (c: SetOf<D>) => SetOf<E>,
|
||||
):(x: SetOf<A>) => SetOf<E>;
|
||||
/* ... etc ... */
|
||||
function compose<T>(...fns: ((x: T) => T)[]): (x: T) => T {
|
||||
return (x: T) => fns.reduce((prev, fn) => fn(prev), x);
|
||||
}
|
||||
|
||||
function map<A, B>(fn: (a: A) => B): (s: SetOf<A>) => SetOf<B> {
|
||||
return (a: SetOf<A>) => {
|
||||
const b: SetOf<B> = new SetOf();
|
||||
a.forEach(x => b.add(fn(x)));
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
function filter<A>(predicate: (a: A) => boolean): (s: SetOf<A>) => SetOf<A> {
|
||||
return (a: SetOf<A>) => {
|
||||
const result = new SetOf<A>();
|
||||
a.forEach(x => {
|
||||
if (predicate(x)) result.add(x);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
const testSet = new SetOf<number>();
|
||||
testSet.add(1);
|
||||
testSet.add(2);
|
||||
testSet.add(3);
|
||||
|
||||
testSet.transform(
|
||||
compose(
|
||||
filter(x => x % 1 === 0),
|
||||
map(x => x + x),
|
||||
map(x => x + '!!!'),
|
||||
map(x => x.toUpperCase())
|
||||
)
|
||||
)
|
||||
|
||||
testSet.transform(
|
||||
compose(
|
||||
filter(x => x % 1 === 0),
|
||||
map(x => x + x),
|
||||
map(x => 123), // Whoops a bug
|
||||
map(x => x.toUpperCase()) // causes an error!
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
//// [inferFromGenericFunctionReturnTypes1.js]
|
||||
// Repro from #15680
|
||||
// This is a contrived class. We could do the same thing with Observables, etc.
|
||||
var SetOf = (function () {
|
||||
function SetOf() {
|
||||
}
|
||||
SetOf.prototype.add = function (a) {
|
||||
this._store.push(a);
|
||||
};
|
||||
SetOf.prototype.transform = function (transformer) {
|
||||
return transformer(this);
|
||||
};
|
||||
SetOf.prototype.forEach = function (fn) {
|
||||
this._store.forEach(function (a, i) { return fn(a, i); });
|
||||
};
|
||||
return SetOf;
|
||||
}());
|
||||
/* ... etc ... */
|
||||
function compose() {
|
||||
var fns = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
fns[_i] = arguments[_i];
|
||||
}
|
||||
return function (x) { return fns.reduce(function (prev, fn) { return fn(prev); }, x); };
|
||||
}
|
||||
function map(fn) {
|
||||
return function (a) {
|
||||
var b = new SetOf();
|
||||
a.forEach(function (x) { return b.add(fn(x)); });
|
||||
return b;
|
||||
};
|
||||
}
|
||||
function filter(predicate) {
|
||||
return function (a) {
|
||||
var result = new SetOf();
|
||||
a.forEach(function (x) {
|
||||
if (predicate(x))
|
||||
result.add(x);
|
||||
});
|
||||
return result;
|
||||
};
|
||||
}
|
||||
var testSet = new SetOf();
|
||||
testSet.add(1);
|
||||
testSet.add(2);
|
||||
testSet.add(3);
|
||||
testSet.transform(compose(filter(function (x) { return x % 1 === 0; }), map(function (x) { return x + x; }), map(function (x) { return x + '!!!'; }), map(function (x) { return x.toUpperCase(); })));
|
||||
testSet.transform(compose(filter(function (x) { return x % 1 === 0; }), map(function (x) { return x + x; }), map(function (x) { return 123; }), // Whoops a bug
|
||||
map(function (x) { return x.toUpperCase(); }) // causes an error!
|
||||
));
|
||||
@@ -0,0 +1,155 @@
|
||||
//// [inferFromGenericFunctionReturnTypes2.ts]
|
||||
type Mapper<T, U> = (x: T) => U;
|
||||
|
||||
declare function wrap<T, U>(cb: Mapper<T, U>): Mapper<T, U>;
|
||||
|
||||
declare function arrayize<T, U>(cb: Mapper<T, U>): Mapper<T, U[]>;
|
||||
|
||||
declare function combine<A, B, C>(f: (x: A) => B, g: (x: B) => C): (x: A) => C;
|
||||
|
||||
declare function foo(f: Mapper<string, number>): void;
|
||||
|
||||
let f1: Mapper<string, number> = s => s.length;
|
||||
let f2: Mapper<string, number> = wrap(s => s.length);
|
||||
let f3: Mapper<string, number[]> = arrayize(wrap(s => s.length));
|
||||
let f4: Mapper<string, boolean> = combine(wrap(s => s.length), wrap(n => n >= 10));
|
||||
|
||||
foo(wrap(s => s.length));
|
||||
|
||||
let a1 = ["a", "b"].map(s => s.length);
|
||||
let a2 = ["a", "b"].map(wrap(s => s.length));
|
||||
let a3 = ["a", "b"].map(wrap(arrayize(s => s.length)));
|
||||
let a4 = ["a", "b"].map(combine(wrap(s => s.length), wrap(n => n > 10)));
|
||||
let a5 = ["a", "b"].map(combine(identity, wrap(s => s.length)));
|
||||
let a6 = ["a", "b"].map(combine(wrap(s => s.length), identity));
|
||||
|
||||
// This is a contrived class. We could do the same thing with Observables, etc.
|
||||
class SetOf<A> {
|
||||
_store: A[];
|
||||
|
||||
add(a: A) {
|
||||
this._store.push(a);
|
||||
}
|
||||
|
||||
transform<B>(transformer: (a: SetOf<A>) => SetOf<B>): SetOf<B> {
|
||||
return transformer(this);
|
||||
}
|
||||
|
||||
forEach(fn: (a: A, index: number) => void) {
|
||||
this._store.forEach((a, i) => fn(a, i));
|
||||
}
|
||||
}
|
||||
|
||||
function compose<A, B, C, D, E>(
|
||||
fnA: (a: SetOf<A>) => SetOf<B>,
|
||||
fnB: (b: SetOf<B>) => SetOf<C>,
|
||||
fnC: (c: SetOf<C>) => SetOf<D>,
|
||||
fnD: (c: SetOf<D>) => SetOf<E>,
|
||||
):(x: SetOf<A>) => SetOf<E>;
|
||||
/* ... etc ... */
|
||||
function compose<T>(...fns: ((x: T) => T)[]): (x: T) => T {
|
||||
return (x: T) => fns.reduce((prev, fn) => fn(prev), x);
|
||||
}
|
||||
|
||||
function map<A, B>(fn: (a: A) => B): (s: SetOf<A>) => SetOf<B> {
|
||||
return (a: SetOf<A>) => {
|
||||
const b: SetOf<B> = new SetOf();
|
||||
a.forEach(x => b.add(fn(x)));
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
function filter<A>(predicate: (a: A) => boolean): (s: SetOf<A>) => SetOf<A> {
|
||||
return (a: SetOf<A>) => {
|
||||
const result = new SetOf<A>();
|
||||
a.forEach(x => {
|
||||
if (predicate(x)) result.add(x);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
const testSet = new SetOf<number>();
|
||||
testSet.add(1);
|
||||
testSet.add(2);
|
||||
testSet.add(3);
|
||||
|
||||
const t1 = testSet.transform(
|
||||
compose(
|
||||
filter(x => x % 1 === 0),
|
||||
map(x => x + x),
|
||||
map(x => x + '!!!'),
|
||||
map(x => x.toUpperCase())
|
||||
)
|
||||
)
|
||||
|
||||
declare function identity<T>(x: T): T;
|
||||
|
||||
const t2 = testSet.transform(
|
||||
compose(
|
||||
filter(x => x % 1 === 0),
|
||||
identity,
|
||||
map(x => x + '!!!'),
|
||||
map(x => x.toUpperCase())
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
//// [inferFromGenericFunctionReturnTypes2.js]
|
||||
var f1 = function (s) { return s.length; };
|
||||
var f2 = wrap(function (s) { return s.length; });
|
||||
var f3 = arrayize(wrap(function (s) { return s.length; }));
|
||||
var f4 = combine(wrap(function (s) { return s.length; }), wrap(function (n) { return n >= 10; }));
|
||||
foo(wrap(function (s) { return s.length; }));
|
||||
var a1 = ["a", "b"].map(function (s) { return s.length; });
|
||||
var a2 = ["a", "b"].map(wrap(function (s) { return s.length; }));
|
||||
var a3 = ["a", "b"].map(wrap(arrayize(function (s) { return s.length; })));
|
||||
var a4 = ["a", "b"].map(combine(wrap(function (s) { return s.length; }), wrap(function (n) { return n > 10; })));
|
||||
var a5 = ["a", "b"].map(combine(identity, wrap(function (s) { return s.length; })));
|
||||
var a6 = ["a", "b"].map(combine(wrap(function (s) { return s.length; }), identity));
|
||||
// This is a contrived class. We could do the same thing with Observables, etc.
|
||||
var SetOf = (function () {
|
||||
function SetOf() {
|
||||
}
|
||||
SetOf.prototype.add = function (a) {
|
||||
this._store.push(a);
|
||||
};
|
||||
SetOf.prototype.transform = function (transformer) {
|
||||
return transformer(this);
|
||||
};
|
||||
SetOf.prototype.forEach = function (fn) {
|
||||
this._store.forEach(function (a, i) { return fn(a, i); });
|
||||
};
|
||||
return SetOf;
|
||||
}());
|
||||
/* ... etc ... */
|
||||
function compose() {
|
||||
var fns = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
fns[_i] = arguments[_i];
|
||||
}
|
||||
return function (x) { return fns.reduce(function (prev, fn) { return fn(prev); }, x); };
|
||||
}
|
||||
function map(fn) {
|
||||
return function (a) {
|
||||
var b = new SetOf();
|
||||
a.forEach(function (x) { return b.add(fn(x)); });
|
||||
return b;
|
||||
};
|
||||
}
|
||||
function filter(predicate) {
|
||||
return function (a) {
|
||||
var result = new SetOf();
|
||||
a.forEach(function (x) {
|
||||
if (predicate(x))
|
||||
result.add(x);
|
||||
});
|
||||
return result;
|
||||
};
|
||||
}
|
||||
var testSet = new SetOf();
|
||||
testSet.add(1);
|
||||
testSet.add(2);
|
||||
testSet.add(3);
|
||||
var t1 = testSet.transform(compose(filter(function (x) { return x % 1 === 0; }), map(function (x) { return x + x; }), map(function (x) { return x + '!!!'; }), map(function (x) { return x.toUpperCase(); })));
|
||||
var t2 = testSet.transform(compose(filter(function (x) { return x % 1 === 0; }), identity, map(function (x) { return x + '!!!'; }), map(function (x) { return x.toUpperCase(); })));
|
||||
@@ -0,0 +1,480 @@
|
||||
=== tests/cases/compiler/inferFromGenericFunctionReturnTypes2.ts ===
|
||||
type Mapper<T, U> = (x: T) => U;
|
||||
>Mapper : Symbol(Mapper, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 12))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 14))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 21))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 12))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 14))
|
||||
|
||||
declare function wrap<T, U>(cb: Mapper<T, U>): Mapper<T, U>;
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 32))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 2, 22))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes2.ts, 2, 24))
|
||||
>cb : Symbol(cb, Decl(inferFromGenericFunctionReturnTypes2.ts, 2, 28))
|
||||
>Mapper : Symbol(Mapper, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 2, 22))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes2.ts, 2, 24))
|
||||
>Mapper : Symbol(Mapper, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 2, 22))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes2.ts, 2, 24))
|
||||
|
||||
declare function arrayize<T, U>(cb: Mapper<T, U>): Mapper<T, U[]>;
|
||||
>arrayize : Symbol(arrayize, Decl(inferFromGenericFunctionReturnTypes2.ts, 2, 60))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 4, 26))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes2.ts, 4, 28))
|
||||
>cb : Symbol(cb, Decl(inferFromGenericFunctionReturnTypes2.ts, 4, 32))
|
||||
>Mapper : Symbol(Mapper, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 4, 26))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes2.ts, 4, 28))
|
||||
>Mapper : Symbol(Mapper, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 4, 26))
|
||||
>U : Symbol(U, Decl(inferFromGenericFunctionReturnTypes2.ts, 4, 28))
|
||||
|
||||
declare function combine<A, B, C>(f: (x: A) => B, g: (x: B) => C): (x: A) => C;
|
||||
>combine : Symbol(combine, Decl(inferFromGenericFunctionReturnTypes2.ts, 4, 66))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 25))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 27))
|
||||
>C : Symbol(C, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 30))
|
||||
>f : Symbol(f, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 34))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 38))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 25))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 27))
|
||||
>g : Symbol(g, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 49))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 54))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 27))
|
||||
>C : Symbol(C, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 30))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 68))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 25))
|
||||
>C : Symbol(C, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 30))
|
||||
|
||||
declare function foo(f: Mapper<string, number>): void;
|
||||
>foo : Symbol(foo, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 79))
|
||||
>f : Symbol(f, Decl(inferFromGenericFunctionReturnTypes2.ts, 8, 21))
|
||||
>Mapper : Symbol(Mapper, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 0))
|
||||
|
||||
let f1: Mapper<string, number> = s => s.length;
|
||||
>f1 : Symbol(f1, Decl(inferFromGenericFunctionReturnTypes2.ts, 10, 3))
|
||||
>Mapper : Symbol(Mapper, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 0))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 10, 32))
|
||||
>s.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 10, 32))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
let f2: Mapper<string, number> = wrap(s => s.length);
|
||||
>f2 : Symbol(f2, Decl(inferFromGenericFunctionReturnTypes2.ts, 11, 3))
|
||||
>Mapper : Symbol(Mapper, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 0))
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 32))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 11, 38))
|
||||
>s.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 11, 38))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
let f3: Mapper<string, number[]> = arrayize(wrap(s => s.length));
|
||||
>f3 : Symbol(f3, Decl(inferFromGenericFunctionReturnTypes2.ts, 12, 3))
|
||||
>Mapper : Symbol(Mapper, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 0))
|
||||
>arrayize : Symbol(arrayize, Decl(inferFromGenericFunctionReturnTypes2.ts, 2, 60))
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 32))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 12, 49))
|
||||
>s.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 12, 49))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
let f4: Mapper<string, boolean> = combine(wrap(s => s.length), wrap(n => n >= 10));
|
||||
>f4 : Symbol(f4, Decl(inferFromGenericFunctionReturnTypes2.ts, 13, 3))
|
||||
>Mapper : Symbol(Mapper, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 0))
|
||||
>combine : Symbol(combine, Decl(inferFromGenericFunctionReturnTypes2.ts, 4, 66))
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 32))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 13, 47))
|
||||
>s.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 13, 47))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 32))
|
||||
>n : Symbol(n, Decl(inferFromGenericFunctionReturnTypes2.ts, 13, 68))
|
||||
>n : Symbol(n, Decl(inferFromGenericFunctionReturnTypes2.ts, 13, 68))
|
||||
|
||||
foo(wrap(s => s.length));
|
||||
>foo : Symbol(foo, Decl(inferFromGenericFunctionReturnTypes2.ts, 6, 79))
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 32))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 15, 9))
|
||||
>s.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 15, 9))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
let a1 = ["a", "b"].map(s => s.length);
|
||||
>a1 : Symbol(a1, Decl(inferFromGenericFunctionReturnTypes2.ts, 17, 3))
|
||||
>["a", "b"].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 17, 24))
|
||||
>s.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 17, 24))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
let a2 = ["a", "b"].map(wrap(s => s.length));
|
||||
>a2 : Symbol(a2, Decl(inferFromGenericFunctionReturnTypes2.ts, 18, 3))
|
||||
>["a", "b"].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 32))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 18, 29))
|
||||
>s.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 18, 29))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
let a3 = ["a", "b"].map(wrap(arrayize(s => s.length)));
|
||||
>a3 : Symbol(a3, Decl(inferFromGenericFunctionReturnTypes2.ts, 19, 3))
|
||||
>["a", "b"].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 32))
|
||||
>arrayize : Symbol(arrayize, Decl(inferFromGenericFunctionReturnTypes2.ts, 2, 60))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 19, 38))
|
||||
>s.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 19, 38))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
let a4 = ["a", "b"].map(combine(wrap(s => s.length), wrap(n => n > 10)));
|
||||
>a4 : Symbol(a4, Decl(inferFromGenericFunctionReturnTypes2.ts, 20, 3))
|
||||
>["a", "b"].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>combine : Symbol(combine, Decl(inferFromGenericFunctionReturnTypes2.ts, 4, 66))
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 32))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 20, 37))
|
||||
>s.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 20, 37))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 32))
|
||||
>n : Symbol(n, Decl(inferFromGenericFunctionReturnTypes2.ts, 20, 58))
|
||||
>n : Symbol(n, Decl(inferFromGenericFunctionReturnTypes2.ts, 20, 58))
|
||||
|
||||
let a5 = ["a", "b"].map(combine(identity, wrap(s => s.length)));
|
||||
>a5 : Symbol(a5, Decl(inferFromGenericFunctionReturnTypes2.ts, 21, 3))
|
||||
>["a", "b"].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>combine : Symbol(combine, Decl(inferFromGenericFunctionReturnTypes2.ts, 4, 66))
|
||||
>identity : Symbol(identity, Decl(inferFromGenericFunctionReturnTypes2.ts, 82, 1))
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 32))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 21, 47))
|
||||
>s.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 21, 47))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
|
||||
let a6 = ["a", "b"].map(combine(wrap(s => s.length), identity));
|
||||
>a6 : Symbol(a6, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 3))
|
||||
>["a", "b"].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>combine : Symbol(combine, Decl(inferFromGenericFunctionReturnTypes2.ts, 4, 66))
|
||||
>wrap : Symbol(wrap, Decl(inferFromGenericFunctionReturnTypes2.ts, 0, 32))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 37))
|
||||
>s.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 37))
|
||||
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
||||
>identity : Symbol(identity, Decl(inferFromGenericFunctionReturnTypes2.ts, 82, 1))
|
||||
|
||||
// This is a contrived class. We could do the same thing with Observables, etc.
|
||||
class SetOf<A> {
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 25, 12))
|
||||
|
||||
_store: A[];
|
||||
>_store : Symbol(SetOf._store, Decl(inferFromGenericFunctionReturnTypes2.ts, 25, 16))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 25, 12))
|
||||
|
||||
add(a: A) {
|
||||
>add : Symbol(SetOf.add, Decl(inferFromGenericFunctionReturnTypes2.ts, 26, 14))
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 28, 6))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 25, 12))
|
||||
|
||||
this._store.push(a);
|
||||
>this._store.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>this._store : Symbol(SetOf._store, Decl(inferFromGenericFunctionReturnTypes2.ts, 25, 16))
|
||||
>this : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>_store : Symbol(SetOf._store, Decl(inferFromGenericFunctionReturnTypes2.ts, 25, 16))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 28, 6))
|
||||
}
|
||||
|
||||
transform<B>(transformer: (a: SetOf<A>) => SetOf<B>): SetOf<B> {
|
||||
>transform : Symbol(SetOf.transform, Decl(inferFromGenericFunctionReturnTypes2.ts, 30, 3))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 32, 12))
|
||||
>transformer : Symbol(transformer, Decl(inferFromGenericFunctionReturnTypes2.ts, 32, 15))
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 32, 29))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 25, 12))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 32, 12))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 32, 12))
|
||||
|
||||
return transformer(this);
|
||||
>transformer : Symbol(transformer, Decl(inferFromGenericFunctionReturnTypes2.ts, 32, 15))
|
||||
>this : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
}
|
||||
|
||||
forEach(fn: (a: A, index: number) => void) {
|
||||
>forEach : Symbol(SetOf.forEach, Decl(inferFromGenericFunctionReturnTypes2.ts, 34, 3))
|
||||
>fn : Symbol(fn, Decl(inferFromGenericFunctionReturnTypes2.ts, 36, 10))
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 36, 15))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 25, 12))
|
||||
>index : Symbol(index, Decl(inferFromGenericFunctionReturnTypes2.ts, 36, 20))
|
||||
|
||||
this._store.forEach((a, i) => fn(a, i));
|
||||
>this._store.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>this._store : Symbol(SetOf._store, Decl(inferFromGenericFunctionReturnTypes2.ts, 25, 16))
|
||||
>this : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>_store : Symbol(SetOf._store, Decl(inferFromGenericFunctionReturnTypes2.ts, 25, 16))
|
||||
>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 37, 27))
|
||||
>i : Symbol(i, Decl(inferFromGenericFunctionReturnTypes2.ts, 37, 29))
|
||||
>fn : Symbol(fn, Decl(inferFromGenericFunctionReturnTypes2.ts, 36, 10))
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 37, 27))
|
||||
>i : Symbol(i, Decl(inferFromGenericFunctionReturnTypes2.ts, 37, 29))
|
||||
}
|
||||
}
|
||||
|
||||
function compose<A, B, C, D, E>(
|
||||
>compose : Symbol(compose, Decl(inferFromGenericFunctionReturnTypes2.ts, 39, 1), Decl(inferFromGenericFunctionReturnTypes2.ts, 46, 28))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 17))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 19))
|
||||
>C : Symbol(C, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 22))
|
||||
>D : Symbol(D, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 25))
|
||||
>E : Symbol(E, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 28))
|
||||
|
||||
fnA: (a: SetOf<A>) => SetOf<B>,
|
||||
>fnA : Symbol(fnA, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 32))
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 42, 8))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 17))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 19))
|
||||
|
||||
fnB: (b: SetOf<B>) => SetOf<C>,
|
||||
>fnB : Symbol(fnB, Decl(inferFromGenericFunctionReturnTypes2.ts, 42, 33))
|
||||
>b : Symbol(b, Decl(inferFromGenericFunctionReturnTypes2.ts, 43, 8))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 19))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>C : Symbol(C, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 22))
|
||||
|
||||
fnC: (c: SetOf<C>) => SetOf<D>,
|
||||
>fnC : Symbol(fnC, Decl(inferFromGenericFunctionReturnTypes2.ts, 43, 33))
|
||||
>c : Symbol(c, Decl(inferFromGenericFunctionReturnTypes2.ts, 44, 8))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>C : Symbol(C, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 22))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>D : Symbol(D, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 25))
|
||||
|
||||
fnD: (c: SetOf<D>) => SetOf<E>,
|
||||
>fnD : Symbol(fnD, Decl(inferFromGenericFunctionReturnTypes2.ts, 44, 33))
|
||||
>c : Symbol(c, Decl(inferFromGenericFunctionReturnTypes2.ts, 45, 8))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>D : Symbol(D, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 25))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>E : Symbol(E, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 28))
|
||||
|
||||
):(x: SetOf<A>) => SetOf<E>;
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 46, 3))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 17))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>E : Symbol(E, Decl(inferFromGenericFunctionReturnTypes2.ts, 41, 28))
|
||||
|
||||
/* ... etc ... */
|
||||
function compose<T>(...fns: ((x: T) => T)[]): (x: T) => T {
|
||||
>compose : Symbol(compose, Decl(inferFromGenericFunctionReturnTypes2.ts, 39, 1), Decl(inferFromGenericFunctionReturnTypes2.ts, 46, 28))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 48, 17))
|
||||
>fns : Symbol(fns, Decl(inferFromGenericFunctionReturnTypes2.ts, 48, 20))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 48, 30))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 48, 17))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 48, 17))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 48, 47))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 48, 17))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 48, 17))
|
||||
|
||||
return (x: T) => fns.reduce((prev, fn) => fn(prev), x);
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 49, 10))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 48, 17))
|
||||
>fns.reduce : Symbol(Array.reduce, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>fns : Symbol(fns, Decl(inferFromGenericFunctionReturnTypes2.ts, 48, 20))
|
||||
>reduce : Symbol(Array.reduce, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>prev : Symbol(prev, Decl(inferFromGenericFunctionReturnTypes2.ts, 49, 31))
|
||||
>fn : Symbol(fn, Decl(inferFromGenericFunctionReturnTypes2.ts, 49, 36))
|
||||
>fn : Symbol(fn, Decl(inferFromGenericFunctionReturnTypes2.ts, 49, 36))
|
||||
>prev : Symbol(prev, Decl(inferFromGenericFunctionReturnTypes2.ts, 49, 31))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 49, 10))
|
||||
}
|
||||
|
||||
function map<A, B>(fn: (a: A) => B): (s: SetOf<A>) => SetOf<B> {
|
||||
>map : Symbol(map, Decl(inferFromGenericFunctionReturnTypes2.ts, 50, 1))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 52, 13))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 52, 15))
|
||||
>fn : Symbol(fn, Decl(inferFromGenericFunctionReturnTypes2.ts, 52, 19))
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 52, 24))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 52, 13))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 52, 15))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 52, 38))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 52, 13))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 52, 15))
|
||||
|
||||
return (a: SetOf<A>) => {
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 53, 10))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 52, 13))
|
||||
|
||||
const b: SetOf<B> = new SetOf();
|
||||
>b : Symbol(b, Decl(inferFromGenericFunctionReturnTypes2.ts, 54, 9))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>B : Symbol(B, Decl(inferFromGenericFunctionReturnTypes2.ts, 52, 15))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
|
||||
a.forEach(x => b.add(fn(x)));
|
||||
>a.forEach : Symbol(SetOf.forEach, Decl(inferFromGenericFunctionReturnTypes2.ts, 34, 3))
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 53, 10))
|
||||
>forEach : Symbol(SetOf.forEach, Decl(inferFromGenericFunctionReturnTypes2.ts, 34, 3))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 55, 14))
|
||||
>b.add : Symbol(SetOf.add, Decl(inferFromGenericFunctionReturnTypes2.ts, 26, 14))
|
||||
>b : Symbol(b, Decl(inferFromGenericFunctionReturnTypes2.ts, 54, 9))
|
||||
>add : Symbol(SetOf.add, Decl(inferFromGenericFunctionReturnTypes2.ts, 26, 14))
|
||||
>fn : Symbol(fn, Decl(inferFromGenericFunctionReturnTypes2.ts, 52, 19))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 55, 14))
|
||||
|
||||
return b;
|
||||
>b : Symbol(b, Decl(inferFromGenericFunctionReturnTypes2.ts, 54, 9))
|
||||
}
|
||||
}
|
||||
|
||||
function filter<A>(predicate: (a: A) => boolean): (s: SetOf<A>) => SetOf<A> {
|
||||
>filter : Symbol(filter, Decl(inferFromGenericFunctionReturnTypes2.ts, 58, 1))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 60, 16))
|
||||
>predicate : Symbol(predicate, Decl(inferFromGenericFunctionReturnTypes2.ts, 60, 19))
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 60, 31))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 60, 16))
|
||||
>s : Symbol(s, Decl(inferFromGenericFunctionReturnTypes2.ts, 60, 51))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 60, 16))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 60, 16))
|
||||
|
||||
return (a: SetOf<A>) => {
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 61, 10))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 60, 16))
|
||||
|
||||
const result = new SetOf<A>();
|
||||
>result : Symbol(result, Decl(inferFromGenericFunctionReturnTypes2.ts, 62, 9))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
>A : Symbol(A, Decl(inferFromGenericFunctionReturnTypes2.ts, 60, 16))
|
||||
|
||||
a.forEach(x => {
|
||||
>a.forEach : Symbol(SetOf.forEach, Decl(inferFromGenericFunctionReturnTypes2.ts, 34, 3))
|
||||
>a : Symbol(a, Decl(inferFromGenericFunctionReturnTypes2.ts, 61, 10))
|
||||
>forEach : Symbol(SetOf.forEach, Decl(inferFromGenericFunctionReturnTypes2.ts, 34, 3))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 63, 14))
|
||||
|
||||
if (predicate(x)) result.add(x);
|
||||
>predicate : Symbol(predicate, Decl(inferFromGenericFunctionReturnTypes2.ts, 60, 19))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 63, 14))
|
||||
>result.add : Symbol(SetOf.add, Decl(inferFromGenericFunctionReturnTypes2.ts, 26, 14))
|
||||
>result : Symbol(result, Decl(inferFromGenericFunctionReturnTypes2.ts, 62, 9))
|
||||
>add : Symbol(SetOf.add, Decl(inferFromGenericFunctionReturnTypes2.ts, 26, 14))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 63, 14))
|
||||
|
||||
});
|
||||
return result;
|
||||
>result : Symbol(result, Decl(inferFromGenericFunctionReturnTypes2.ts, 62, 9))
|
||||
}
|
||||
}
|
||||
|
||||
const testSet = new SetOf<number>();
|
||||
>testSet : Symbol(testSet, Decl(inferFromGenericFunctionReturnTypes2.ts, 70, 5))
|
||||
>SetOf : Symbol(SetOf, Decl(inferFromGenericFunctionReturnTypes2.ts, 22, 64))
|
||||
|
||||
testSet.add(1);
|
||||
>testSet.add : Symbol(SetOf.add, Decl(inferFromGenericFunctionReturnTypes2.ts, 26, 14))
|
||||
>testSet : Symbol(testSet, Decl(inferFromGenericFunctionReturnTypes2.ts, 70, 5))
|
||||
>add : Symbol(SetOf.add, Decl(inferFromGenericFunctionReturnTypes2.ts, 26, 14))
|
||||
|
||||
testSet.add(2);
|
||||
>testSet.add : Symbol(SetOf.add, Decl(inferFromGenericFunctionReturnTypes2.ts, 26, 14))
|
||||
>testSet : Symbol(testSet, Decl(inferFromGenericFunctionReturnTypes2.ts, 70, 5))
|
||||
>add : Symbol(SetOf.add, Decl(inferFromGenericFunctionReturnTypes2.ts, 26, 14))
|
||||
|
||||
testSet.add(3);
|
||||
>testSet.add : Symbol(SetOf.add, Decl(inferFromGenericFunctionReturnTypes2.ts, 26, 14))
|
||||
>testSet : Symbol(testSet, Decl(inferFromGenericFunctionReturnTypes2.ts, 70, 5))
|
||||
>add : Symbol(SetOf.add, Decl(inferFromGenericFunctionReturnTypes2.ts, 26, 14))
|
||||
|
||||
const t1 = testSet.transform(
|
||||
>t1 : Symbol(t1, Decl(inferFromGenericFunctionReturnTypes2.ts, 75, 5))
|
||||
>testSet.transform : Symbol(SetOf.transform, Decl(inferFromGenericFunctionReturnTypes2.ts, 30, 3))
|
||||
>testSet : Symbol(testSet, Decl(inferFromGenericFunctionReturnTypes2.ts, 70, 5))
|
||||
>transform : Symbol(SetOf.transform, Decl(inferFromGenericFunctionReturnTypes2.ts, 30, 3))
|
||||
|
||||
compose(
|
||||
>compose : Symbol(compose, Decl(inferFromGenericFunctionReturnTypes2.ts, 39, 1), Decl(inferFromGenericFunctionReturnTypes2.ts, 46, 28))
|
||||
|
||||
filter(x => x % 1 === 0),
|
||||
>filter : Symbol(filter, Decl(inferFromGenericFunctionReturnTypes2.ts, 58, 1))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 77, 11))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 77, 11))
|
||||
|
||||
map(x => x + x),
|
||||
>map : Symbol(map, Decl(inferFromGenericFunctionReturnTypes2.ts, 50, 1))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 78, 8))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 78, 8))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 78, 8))
|
||||
|
||||
map(x => x + '!!!'),
|
||||
>map : Symbol(map, Decl(inferFromGenericFunctionReturnTypes2.ts, 50, 1))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 79, 8))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 79, 8))
|
||||
|
||||
map(x => x.toUpperCase())
|
||||
>map : Symbol(map, Decl(inferFromGenericFunctionReturnTypes2.ts, 50, 1))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 80, 8))
|
||||
>x.toUpperCase : Symbol(String.toUpperCase, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 80, 8))
|
||||
>toUpperCase : Symbol(String.toUpperCase, Decl(lib.d.ts, --, --))
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
declare function identity<T>(x: T): T;
|
||||
>identity : Symbol(identity, Decl(inferFromGenericFunctionReturnTypes2.ts, 82, 1))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 84, 26))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 84, 29))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 84, 26))
|
||||
>T : Symbol(T, Decl(inferFromGenericFunctionReturnTypes2.ts, 84, 26))
|
||||
|
||||
const t2 = testSet.transform(
|
||||
>t2 : Symbol(t2, Decl(inferFromGenericFunctionReturnTypes2.ts, 86, 5))
|
||||
>testSet.transform : Symbol(SetOf.transform, Decl(inferFromGenericFunctionReturnTypes2.ts, 30, 3))
|
||||
>testSet : Symbol(testSet, Decl(inferFromGenericFunctionReturnTypes2.ts, 70, 5))
|
||||
>transform : Symbol(SetOf.transform, Decl(inferFromGenericFunctionReturnTypes2.ts, 30, 3))
|
||||
|
||||
compose(
|
||||
>compose : Symbol(compose, Decl(inferFromGenericFunctionReturnTypes2.ts, 39, 1), Decl(inferFromGenericFunctionReturnTypes2.ts, 46, 28))
|
||||
|
||||
filter(x => x % 1 === 0),
|
||||
>filter : Symbol(filter, Decl(inferFromGenericFunctionReturnTypes2.ts, 58, 1))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 88, 11))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 88, 11))
|
||||
|
||||
identity,
|
||||
>identity : Symbol(identity, Decl(inferFromGenericFunctionReturnTypes2.ts, 82, 1))
|
||||
|
||||
map(x => x + '!!!'),
|
||||
>map : Symbol(map, Decl(inferFromGenericFunctionReturnTypes2.ts, 50, 1))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 90, 8))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 90, 8))
|
||||
|
||||
map(x => x.toUpperCase())
|
||||
>map : Symbol(map, Decl(inferFromGenericFunctionReturnTypes2.ts, 50, 1))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 91, 8))
|
||||
>x.toUpperCase : Symbol(String.toUpperCase, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(inferFromGenericFunctionReturnTypes2.ts, 91, 8))
|
||||
>toUpperCase : Symbol(String.toUpperCase, Decl(lib.d.ts, --, --))
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
@@ -0,0 +1,600 @@
|
||||
=== tests/cases/compiler/inferFromGenericFunctionReturnTypes2.ts ===
|
||||
type Mapper<T, U> = (x: T) => U;
|
||||
>Mapper : Mapper<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
>x : T
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
declare function wrap<T, U>(cb: Mapper<T, U>): Mapper<T, U>;
|
||||
>wrap : <T, U>(cb: Mapper<T, U>) => Mapper<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
>cb : Mapper<T, U>
|
||||
>Mapper : Mapper<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
>Mapper : Mapper<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
declare function arrayize<T, U>(cb: Mapper<T, U>): Mapper<T, U[]>;
|
||||
>arrayize : <T, U>(cb: Mapper<T, U>) => Mapper<T, U[]>
|
||||
>T : T
|
||||
>U : U
|
||||
>cb : Mapper<T, U>
|
||||
>Mapper : Mapper<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
>Mapper : Mapper<T, U>
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
declare function combine<A, B, C>(f: (x: A) => B, g: (x: B) => C): (x: A) => C;
|
||||
>combine : <A, B, C>(f: (x: A) => B, g: (x: B) => C) => (x: A) => C
|
||||
>A : A
|
||||
>B : B
|
||||
>C : C
|
||||
>f : (x: A) => B
|
||||
>x : A
|
||||
>A : A
|
||||
>B : B
|
||||
>g : (x: B) => C
|
||||
>x : B
|
||||
>B : B
|
||||
>C : C
|
||||
>x : A
|
||||
>A : A
|
||||
>C : C
|
||||
|
||||
declare function foo(f: Mapper<string, number>): void;
|
||||
>foo : (f: Mapper<string, number>) => void
|
||||
>f : Mapper<string, number>
|
||||
>Mapper : Mapper<T, U>
|
||||
|
||||
let f1: Mapper<string, number> = s => s.length;
|
||||
>f1 : Mapper<string, number>
|
||||
>Mapper : Mapper<T, U>
|
||||
>s => s.length : (s: string) => number
|
||||
>s : string
|
||||
>s.length : number
|
||||
>s : string
|
||||
>length : number
|
||||
|
||||
let f2: Mapper<string, number> = wrap(s => s.length);
|
||||
>f2 : Mapper<string, number>
|
||||
>Mapper : Mapper<T, U>
|
||||
>wrap(s => s.length) : Mapper<string, number>
|
||||
>wrap : <T, U>(cb: Mapper<T, U>) => Mapper<T, U>
|
||||
>s => s.length : (s: string) => number
|
||||
>s : string
|
||||
>s.length : number
|
||||
>s : string
|
||||
>length : number
|
||||
|
||||
let f3: Mapper<string, number[]> = arrayize(wrap(s => s.length));
|
||||
>f3 : Mapper<string, number[]>
|
||||
>Mapper : Mapper<T, U>
|
||||
>arrayize(wrap(s => s.length)) : Mapper<string, number[]>
|
||||
>arrayize : <T, U>(cb: Mapper<T, U>) => Mapper<T, U[]>
|
||||
>wrap(s => s.length) : Mapper<string, number>
|
||||
>wrap : <T, U>(cb: Mapper<T, U>) => Mapper<T, U>
|
||||
>s => s.length : (s: string) => number
|
||||
>s : string
|
||||
>s.length : number
|
||||
>s : string
|
||||
>length : number
|
||||
|
||||
let f4: Mapper<string, boolean> = combine(wrap(s => s.length), wrap(n => n >= 10));
|
||||
>f4 : Mapper<string, boolean>
|
||||
>Mapper : Mapper<T, U>
|
||||
>combine(wrap(s => s.length), wrap(n => n >= 10)) : (x: string) => boolean
|
||||
>combine : <A, B, C>(f: (x: A) => B, g: (x: B) => C) => (x: A) => C
|
||||
>wrap(s => s.length) : Mapper<string, number>
|
||||
>wrap : <T, U>(cb: Mapper<T, U>) => Mapper<T, U>
|
||||
>s => s.length : (s: string) => number
|
||||
>s : string
|
||||
>s.length : number
|
||||
>s : string
|
||||
>length : number
|
||||
>wrap(n => n >= 10) : Mapper<number, boolean>
|
||||
>wrap : <T, U>(cb: Mapper<T, U>) => Mapper<T, U>
|
||||
>n => n >= 10 : (n: number) => boolean
|
||||
>n : number
|
||||
>n >= 10 : boolean
|
||||
>n : number
|
||||
>10 : 10
|
||||
|
||||
foo(wrap(s => s.length));
|
||||
>foo(wrap(s => s.length)) : void
|
||||
>foo : (f: Mapper<string, number>) => void
|
||||
>wrap(s => s.length) : Mapper<string, number>
|
||||
>wrap : <T, U>(cb: Mapper<T, U>) => Mapper<T, U>
|
||||
>s => s.length : (s: string) => number
|
||||
>s : string
|
||||
>s.length : number
|
||||
>s : string
|
||||
>length : number
|
||||
|
||||
let a1 = ["a", "b"].map(s => s.length);
|
||||
>a1 : number[]
|
||||
>["a", "b"].map(s => s.length) : number[]
|
||||
>["a", "b"].map : { <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
||||
>["a", "b"] : string[]
|
||||
>"a" : "a"
|
||||
>"b" : "b"
|
||||
>map : { <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
||||
>s => s.length : (this: void, s: string) => number
|
||||
>s : string
|
||||
>s.length : number
|
||||
>s : string
|
||||
>length : number
|
||||
|
||||
let a2 = ["a", "b"].map(wrap(s => s.length));
|
||||
>a2 : number[]
|
||||
>["a", "b"].map(wrap(s => s.length)) : number[]
|
||||
>["a", "b"].map : { <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
||||
>["a", "b"] : string[]
|
||||
>"a" : "a"
|
||||
>"b" : "b"
|
||||
>map : { <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
||||
>wrap(s => s.length) : Mapper<string, number>
|
||||
>wrap : <T, U>(cb: Mapper<T, U>) => Mapper<T, U>
|
||||
>s => s.length : (s: string) => number
|
||||
>s : string
|
||||
>s.length : number
|
||||
>s : string
|
||||
>length : number
|
||||
|
||||
let a3 = ["a", "b"].map(wrap(arrayize(s => s.length)));
|
||||
>a3 : number[][]
|
||||
>["a", "b"].map(wrap(arrayize(s => s.length))) : number[][]
|
||||
>["a", "b"].map : { <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
||||
>["a", "b"] : string[]
|
||||
>"a" : "a"
|
||||
>"b" : "b"
|
||||
>map : { <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
||||
>wrap(arrayize(s => s.length)) : Mapper<string, number[]>
|
||||
>wrap : <T, U>(cb: Mapper<T, U>) => Mapper<T, U>
|
||||
>arrayize(s => s.length) : Mapper<string, number[]>
|
||||
>arrayize : <T, U>(cb: Mapper<T, U>) => Mapper<T, U[]>
|
||||
>s => s.length : (s: string) => number
|
||||
>s : string
|
||||
>s.length : number
|
||||
>s : string
|
||||
>length : number
|
||||
|
||||
let a4 = ["a", "b"].map(combine(wrap(s => s.length), wrap(n => n > 10)));
|
||||
>a4 : boolean[]
|
||||
>["a", "b"].map(combine(wrap(s => s.length), wrap(n => n > 10))) : boolean[]
|
||||
>["a", "b"].map : { <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
||||
>["a", "b"] : string[]
|
||||
>"a" : "a"
|
||||
>"b" : "b"
|
||||
>map : { <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
||||
>combine(wrap(s => s.length), wrap(n => n > 10)) : (x: string) => boolean
|
||||
>combine : <A, B, C>(f: (x: A) => B, g: (x: B) => C) => (x: A) => C
|
||||
>wrap(s => s.length) : Mapper<string, number>
|
||||
>wrap : <T, U>(cb: Mapper<T, U>) => Mapper<T, U>
|
||||
>s => s.length : (s: string) => number
|
||||
>s : string
|
||||
>s.length : number
|
||||
>s : string
|
||||
>length : number
|
||||
>wrap(n => n > 10) : Mapper<number, boolean>
|
||||
>wrap : <T, U>(cb: Mapper<T, U>) => Mapper<T, U>
|
||||
>n => n > 10 : (n: number) => boolean
|
||||
>n : number
|
||||
>n > 10 : boolean
|
||||
>n : number
|
||||
>10 : 10
|
||||
|
||||
let a5 = ["a", "b"].map(combine(identity, wrap(s => s.length)));
|
||||
>a5 : number[]
|
||||
>["a", "b"].map(combine(identity, wrap(s => s.length))) : number[]
|
||||
>["a", "b"].map : { <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
||||
>["a", "b"] : string[]
|
||||
>"a" : "a"
|
||||
>"b" : "b"
|
||||
>map : { <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
||||
>combine(identity, wrap(s => s.length)) : (x: string) => number
|
||||
>combine : <A, B, C>(f: (x: A) => B, g: (x: B) => C) => (x: A) => C
|
||||
>identity : <T>(x: T) => T
|
||||
>wrap(s => s.length) : Mapper<string, number>
|
||||
>wrap : <T, U>(cb: Mapper<T, U>) => Mapper<T, U>
|
||||
>s => s.length : (s: string) => number
|
||||
>s : string
|
||||
>s.length : number
|
||||
>s : string
|
||||
>length : number
|
||||
|
||||
let a6 = ["a", "b"].map(combine(wrap(s => s.length), identity));
|
||||
>a6 : number[]
|
||||
>["a", "b"].map(combine(wrap(s => s.length), identity)) : number[]
|
||||
>["a", "b"].map : { <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
||||
>["a", "b"] : string[]
|
||||
>"a" : "a"
|
||||
>"b" : "b"
|
||||
>map : { <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; <U>(this: [string, string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; <Z, U>(this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U, U]; <U>(this: [string, string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; <Z, U>(this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U, U]; <U>(this: [string, string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; <Z, U>(this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U): [U, U]; <U>(this: [string, string], callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; <Z, U>(this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U): U[]; <U>(callbackfn: (this: void, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; <Z, U>(callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; }
|
||||
>combine(wrap(s => s.length), identity) : (x: string) => number
|
||||
>combine : <A, B, C>(f: (x: A) => B, g: (x: B) => C) => (x: A) => C
|
||||
>wrap(s => s.length) : Mapper<string, number>
|
||||
>wrap : <T, U>(cb: Mapper<T, U>) => Mapper<T, U>
|
||||
>s => s.length : (s: string) => number
|
||||
>s : string
|
||||
>s.length : number
|
||||
>s : string
|
||||
>length : number
|
||||
>identity : <T>(x: T) => T
|
||||
|
||||
// This is a contrived class. We could do the same thing with Observables, etc.
|
||||
class SetOf<A> {
|
||||
>SetOf : SetOf<A>
|
||||
>A : A
|
||||
|
||||
_store: A[];
|
||||
>_store : A[]
|
||||
>A : A
|
||||
|
||||
add(a: A) {
|
||||
>add : (a: A) => void
|
||||
>a : A
|
||||
>A : A
|
||||
|
||||
this._store.push(a);
|
||||
>this._store.push(a) : number
|
||||
>this._store.push : (...items: A[]) => number
|
||||
>this._store : A[]
|
||||
>this : this
|
||||
>_store : A[]
|
||||
>push : (...items: A[]) => number
|
||||
>a : A
|
||||
}
|
||||
|
||||
transform<B>(transformer: (a: SetOf<A>) => SetOf<B>): SetOf<B> {
|
||||
>transform : <B>(transformer: (a: SetOf<A>) => SetOf<B>) => SetOf<B>
|
||||
>B : B
|
||||
>transformer : (a: SetOf<A>) => SetOf<B>
|
||||
>a : SetOf<A>
|
||||
>SetOf : SetOf<A>
|
||||
>A : A
|
||||
>SetOf : SetOf<A>
|
||||
>B : B
|
||||
>SetOf : SetOf<A>
|
||||
>B : B
|
||||
|
||||
return transformer(this);
|
||||
>transformer(this) : SetOf<B>
|
||||
>transformer : (a: SetOf<A>) => SetOf<B>
|
||||
>this : this
|
||||
}
|
||||
|
||||
forEach(fn: (a: A, index: number) => void) {
|
||||
>forEach : (fn: (a: A, index: number) => void) => void
|
||||
>fn : (a: A, index: number) => void
|
||||
>a : A
|
||||
>A : A
|
||||
>index : number
|
||||
|
||||
this._store.forEach((a, i) => fn(a, i));
|
||||
>this._store.forEach((a, i) => fn(a, i)) : void
|
||||
>this._store.forEach : { (callbackfn: (this: void, value: A, index: number, array: A[]) => void): void; (callbackfn: (this: void, value: A, index: number, array: A[]) => void, thisArg: undefined): void; <Z>(callbackfn: (this: Z, value: A, index: number, array: A[]) => void, thisArg: Z): void; }
|
||||
>this._store : A[]
|
||||
>this : this
|
||||
>_store : A[]
|
||||
>forEach : { (callbackfn: (this: void, value: A, index: number, array: A[]) => void): void; (callbackfn: (this: void, value: A, index: number, array: A[]) => void, thisArg: undefined): void; <Z>(callbackfn: (this: Z, value: A, index: number, array: A[]) => void, thisArg: Z): void; }
|
||||
>(a, i) => fn(a, i) : (this: void, a: A, i: number) => void
|
||||
>a : A
|
||||
>i : number
|
||||
>fn(a, i) : void
|
||||
>fn : (a: A, index: number) => void
|
||||
>a : A
|
||||
>i : number
|
||||
}
|
||||
}
|
||||
|
||||
function compose<A, B, C, D, E>(
|
||||
>compose : <A, B, C, D, E>(fnA: (a: SetOf<A>) => SetOf<B>, fnB: (b: SetOf<B>) => SetOf<C>, fnC: (c: SetOf<C>) => SetOf<D>, fnD: (c: SetOf<D>) => SetOf<E>) => (x: SetOf<A>) => SetOf<E>
|
||||
>A : A
|
||||
>B : B
|
||||
>C : C
|
||||
>D : D
|
||||
>E : E
|
||||
|
||||
fnA: (a: SetOf<A>) => SetOf<B>,
|
||||
>fnA : (a: SetOf<A>) => SetOf<B>
|
||||
>a : SetOf<A>
|
||||
>SetOf : SetOf<A>
|
||||
>A : A
|
||||
>SetOf : SetOf<A>
|
||||
>B : B
|
||||
|
||||
fnB: (b: SetOf<B>) => SetOf<C>,
|
||||
>fnB : (b: SetOf<B>) => SetOf<C>
|
||||
>b : SetOf<B>
|
||||
>SetOf : SetOf<A>
|
||||
>B : B
|
||||
>SetOf : SetOf<A>
|
||||
>C : C
|
||||
|
||||
fnC: (c: SetOf<C>) => SetOf<D>,
|
||||
>fnC : (c: SetOf<C>) => SetOf<D>
|
||||
>c : SetOf<C>
|
||||
>SetOf : SetOf<A>
|
||||
>C : C
|
||||
>SetOf : SetOf<A>
|
||||
>D : D
|
||||
|
||||
fnD: (c: SetOf<D>) => SetOf<E>,
|
||||
>fnD : (c: SetOf<D>) => SetOf<E>
|
||||
>c : SetOf<D>
|
||||
>SetOf : SetOf<A>
|
||||
>D : D
|
||||
>SetOf : SetOf<A>
|
||||
>E : E
|
||||
|
||||
):(x: SetOf<A>) => SetOf<E>;
|
||||
>x : SetOf<A>
|
||||
>SetOf : SetOf<A>
|
||||
>A : A
|
||||
>SetOf : SetOf<A>
|
||||
>E : E
|
||||
|
||||
/* ... etc ... */
|
||||
function compose<T>(...fns: ((x: T) => T)[]): (x: T) => T {
|
||||
>compose : <A, B, C, D, E>(fnA: (a: SetOf<A>) => SetOf<B>, fnB: (b: SetOf<B>) => SetOf<C>, fnC: (c: SetOf<C>) => SetOf<D>, fnD: (c: SetOf<D>) => SetOf<E>) => (x: SetOf<A>) => SetOf<E>
|
||||
>T : T
|
||||
>fns : ((x: T) => T)[]
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return (x: T) => fns.reduce((prev, fn) => fn(prev), x);
|
||||
>(x: T) => fns.reduce((prev, fn) => fn(prev), x) : (x: T) => T
|
||||
>x : T
|
||||
>T : T
|
||||
>fns.reduce((prev, fn) => fn(prev), x) : T
|
||||
>fns.reduce : { (callbackfn: (previousValue: (x: T) => T, currentValue: (x: T) => T, currentIndex: number, array: ((x: T) => T)[]) => (x: T) => T, initialValue?: (x: T) => T): (x: T) => T; <U>(callbackfn: (previousValue: U, currentValue: (x: T) => T, currentIndex: number, array: ((x: T) => T)[]) => U, initialValue: U): U; }
|
||||
>fns : ((x: T) => T)[]
|
||||
>reduce : { (callbackfn: (previousValue: (x: T) => T, currentValue: (x: T) => T, currentIndex: number, array: ((x: T) => T)[]) => (x: T) => T, initialValue?: (x: T) => T): (x: T) => T; <U>(callbackfn: (previousValue: U, currentValue: (x: T) => T, currentIndex: number, array: ((x: T) => T)[]) => U, initialValue: U): U; }
|
||||
>(prev, fn) => fn(prev) : (prev: T, fn: (x: T) => T) => T
|
||||
>prev : T
|
||||
>fn : (x: T) => T
|
||||
>fn(prev) : T
|
||||
>fn : (x: T) => T
|
||||
>prev : T
|
||||
>x : T
|
||||
}
|
||||
|
||||
function map<A, B>(fn: (a: A) => B): (s: SetOf<A>) => SetOf<B> {
|
||||
>map : <A, B>(fn: (a: A) => B) => (s: SetOf<A>) => SetOf<B>
|
||||
>A : A
|
||||
>B : B
|
||||
>fn : (a: A) => B
|
||||
>a : A
|
||||
>A : A
|
||||
>B : B
|
||||
>s : SetOf<A>
|
||||
>SetOf : SetOf<A>
|
||||
>A : A
|
||||
>SetOf : SetOf<A>
|
||||
>B : B
|
||||
|
||||
return (a: SetOf<A>) => {
|
||||
>(a: SetOf<A>) => { const b: SetOf<B> = new SetOf(); a.forEach(x => b.add(fn(x))); return b; } : (a: SetOf<A>) => SetOf<B>
|
||||
>a : SetOf<A>
|
||||
>SetOf : SetOf<A>
|
||||
>A : A
|
||||
|
||||
const b: SetOf<B> = new SetOf();
|
||||
>b : SetOf<B>
|
||||
>SetOf : SetOf<A>
|
||||
>B : B
|
||||
>new SetOf() : SetOf<B>
|
||||
>SetOf : typeof SetOf
|
||||
|
||||
a.forEach(x => b.add(fn(x)));
|
||||
>a.forEach(x => b.add(fn(x))) : void
|
||||
>a.forEach : (fn: (a: A, index: number) => void) => void
|
||||
>a : SetOf<A>
|
||||
>forEach : (fn: (a: A, index: number) => void) => void
|
||||
>x => b.add(fn(x)) : (x: A) => void
|
||||
>x : A
|
||||
>b.add(fn(x)) : void
|
||||
>b.add : (a: B) => void
|
||||
>b : SetOf<B>
|
||||
>add : (a: B) => void
|
||||
>fn(x) : B
|
||||
>fn : (a: A) => B
|
||||
>x : A
|
||||
|
||||
return b;
|
||||
>b : SetOf<B>
|
||||
}
|
||||
}
|
||||
|
||||
function filter<A>(predicate: (a: A) => boolean): (s: SetOf<A>) => SetOf<A> {
|
||||
>filter : <A>(predicate: (a: A) => boolean) => (s: SetOf<A>) => SetOf<A>
|
||||
>A : A
|
||||
>predicate : (a: A) => boolean
|
||||
>a : A
|
||||
>A : A
|
||||
>s : SetOf<A>
|
||||
>SetOf : SetOf<A>
|
||||
>A : A
|
||||
>SetOf : SetOf<A>
|
||||
>A : A
|
||||
|
||||
return (a: SetOf<A>) => {
|
||||
>(a: SetOf<A>) => { const result = new SetOf<A>(); a.forEach(x => { if (predicate(x)) result.add(x); }); return result; } : (a: SetOf<A>) => SetOf<A>
|
||||
>a : SetOf<A>
|
||||
>SetOf : SetOf<A>
|
||||
>A : A
|
||||
|
||||
const result = new SetOf<A>();
|
||||
>result : SetOf<A>
|
||||
>new SetOf<A>() : SetOf<A>
|
||||
>SetOf : typeof SetOf
|
||||
>A : A
|
||||
|
||||
a.forEach(x => {
|
||||
>a.forEach(x => { if (predicate(x)) result.add(x); }) : void
|
||||
>a.forEach : (fn: (a: A, index: number) => void) => void
|
||||
>a : SetOf<A>
|
||||
>forEach : (fn: (a: A, index: number) => void) => void
|
||||
>x => { if (predicate(x)) result.add(x); } : (x: A) => void
|
||||
>x : A
|
||||
|
||||
if (predicate(x)) result.add(x);
|
||||
>predicate(x) : boolean
|
||||
>predicate : (a: A) => boolean
|
||||
>x : A
|
||||
>result.add(x) : void
|
||||
>result.add : (a: A) => void
|
||||
>result : SetOf<A>
|
||||
>add : (a: A) => void
|
||||
>x : A
|
||||
|
||||
});
|
||||
return result;
|
||||
>result : SetOf<A>
|
||||
}
|
||||
}
|
||||
|
||||
const testSet = new SetOf<number>();
|
||||
>testSet : SetOf<number>
|
||||
>new SetOf<number>() : SetOf<number>
|
||||
>SetOf : typeof SetOf
|
||||
|
||||
testSet.add(1);
|
||||
>testSet.add(1) : void
|
||||
>testSet.add : (a: number) => void
|
||||
>testSet : SetOf<number>
|
||||
>add : (a: number) => void
|
||||
>1 : 1
|
||||
|
||||
testSet.add(2);
|
||||
>testSet.add(2) : void
|
||||
>testSet.add : (a: number) => void
|
||||
>testSet : SetOf<number>
|
||||
>add : (a: number) => void
|
||||
>2 : 2
|
||||
|
||||
testSet.add(3);
|
||||
>testSet.add(3) : void
|
||||
>testSet.add : (a: number) => void
|
||||
>testSet : SetOf<number>
|
||||
>add : (a: number) => void
|
||||
>3 : 3
|
||||
|
||||
const t1 = testSet.transform(
|
||||
>t1 : SetOf<string>
|
||||
>testSet.transform( compose( filter(x => x % 1 === 0), map(x => x + x), map(x => x + '!!!'), map(x => x.toUpperCase()) )) : SetOf<string>
|
||||
>testSet.transform : <B>(transformer: (a: SetOf<number>) => SetOf<B>) => SetOf<B>
|
||||
>testSet : SetOf<number>
|
||||
>transform : <B>(transformer: (a: SetOf<number>) => SetOf<B>) => SetOf<B>
|
||||
|
||||
compose(
|
||||
>compose( filter(x => x % 1 === 0), map(x => x + x), map(x => x + '!!!'), map(x => x.toUpperCase()) ) : (x: SetOf<number>) => SetOf<string>
|
||||
>compose : <A, B, C, D, E>(fnA: (a: SetOf<A>) => SetOf<B>, fnB: (b: SetOf<B>) => SetOf<C>, fnC: (c: SetOf<C>) => SetOf<D>, fnD: (c: SetOf<D>) => SetOf<E>) => (x: SetOf<A>) => SetOf<E>
|
||||
|
||||
filter(x => x % 1 === 0),
|
||||
>filter(x => x % 1 === 0) : (s: SetOf<number>) => SetOf<number>
|
||||
>filter : <A>(predicate: (a: A) => boolean) => (s: SetOf<A>) => SetOf<A>
|
||||
>x => x % 1 === 0 : (x: number) => boolean
|
||||
>x : number
|
||||
>x % 1 === 0 : boolean
|
||||
>x % 1 : number
|
||||
>x : number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
map(x => x + x),
|
||||
>map(x => x + x) : (s: SetOf<number>) => SetOf<number>
|
||||
>map : <A, B>(fn: (a: A) => B) => (s: SetOf<A>) => SetOf<B>
|
||||
>x => x + x : (x: number) => number
|
||||
>x : number
|
||||
>x + x : number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
map(x => x + '!!!'),
|
||||
>map(x => x + '!!!') : (s: SetOf<number>) => SetOf<string>
|
||||
>map : <A, B>(fn: (a: A) => B) => (s: SetOf<A>) => SetOf<B>
|
||||
>x => x + '!!!' : (x: number) => string
|
||||
>x : number
|
||||
>x + '!!!' : string
|
||||
>x : number
|
||||
>'!!!' : "!!!"
|
||||
|
||||
map(x => x.toUpperCase())
|
||||
>map(x => x.toUpperCase()) : (s: SetOf<string>) => SetOf<string>
|
||||
>map : <A, B>(fn: (a: A) => B) => (s: SetOf<A>) => SetOf<B>
|
||||
>x => x.toUpperCase() : (x: string) => string
|
||||
>x : string
|
||||
>x.toUpperCase() : string
|
||||
>x.toUpperCase : () => string
|
||||
>x : string
|
||||
>toUpperCase : () => string
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
declare function identity<T>(x: T): T;
|
||||
>identity : <T>(x: T) => T
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
const t2 = testSet.transform(
|
||||
>t2 : SetOf<string>
|
||||
>testSet.transform( compose( filter(x => x % 1 === 0), identity, map(x => x + '!!!'), map(x => x.toUpperCase()) )) : SetOf<string>
|
||||
>testSet.transform : <B>(transformer: (a: SetOf<number>) => SetOf<B>) => SetOf<B>
|
||||
>testSet : SetOf<number>
|
||||
>transform : <B>(transformer: (a: SetOf<number>) => SetOf<B>) => SetOf<B>
|
||||
|
||||
compose(
|
||||
>compose( filter(x => x % 1 === 0), identity, map(x => x + '!!!'), map(x => x.toUpperCase()) ) : (x: SetOf<number>) => SetOf<string>
|
||||
>compose : <A, B, C, D, E>(fnA: (a: SetOf<A>) => SetOf<B>, fnB: (b: SetOf<B>) => SetOf<C>, fnC: (c: SetOf<C>) => SetOf<D>, fnD: (c: SetOf<D>) => SetOf<E>) => (x: SetOf<A>) => SetOf<E>
|
||||
|
||||
filter(x => x % 1 === 0),
|
||||
>filter(x => x % 1 === 0) : (s: SetOf<number>) => SetOf<number>
|
||||
>filter : <A>(predicate: (a: A) => boolean) => (s: SetOf<A>) => SetOf<A>
|
||||
>x => x % 1 === 0 : (x: number) => boolean
|
||||
>x : number
|
||||
>x % 1 === 0 : boolean
|
||||
>x % 1 : number
|
||||
>x : number
|
||||
>1 : 1
|
||||
>0 : 0
|
||||
|
||||
identity,
|
||||
>identity : <T>(x: T) => T
|
||||
|
||||
map(x => x + '!!!'),
|
||||
>map(x => x + '!!!') : (s: SetOf<number>) => SetOf<string>
|
||||
>map : <A, B>(fn: (a: A) => B) => (s: SetOf<A>) => SetOf<B>
|
||||
>x => x + '!!!' : (x: number) => string
|
||||
>x : number
|
||||
>x + '!!!' : string
|
||||
>x : number
|
||||
>'!!!' : "!!!"
|
||||
|
||||
map(x => x.toUpperCase())
|
||||
>map(x => x.toUpperCase()) : (s: SetOf<string>) => SetOf<string>
|
||||
>map : <A, B>(fn: (a: A) => B) => (s: SetOf<A>) => SetOf<B>
|
||||
>x => x.toUpperCase() : (x: string) => string
|
||||
>x : string
|
||||
>x.toUpperCase() : string
|
||||
>x.toUpperCase : () => string
|
||||
>x : string
|
||||
>toUpperCase : () => string
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user