mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
27 lines
1.3 KiB
Plaintext
27 lines
1.3 KiB
Plaintext
genericFunctionsWithOptionalParameters3.ts(10,10): error TS2454: Variable 'utils' is used before being assigned.
|
|
genericFunctionsWithOptionalParameters3.ts(11,10): error TS2454: Variable 'utils' is used before being assigned.
|
|
genericFunctionsWithOptionalParameters3.ts(14,10): error TS2454: Variable 'utils' is used before being assigned.
|
|
|
|
|
|
==== genericFunctionsWithOptionalParameters3.ts (3 errors) ====
|
|
class Collection<T> {
|
|
public add(x: T) { }
|
|
}
|
|
interface Utils {
|
|
fold<T, S>(c?: Collection<T>, folder?: (s: S, t: T) => T, init?: S): T;
|
|
mapReduce<T, U, V>(c: Collection<T>, mapper: (x: T) => U, reducer: (y: U) => V): Collection<V>;
|
|
}
|
|
var utils: Utils;
|
|
var c = new Collection<string>();
|
|
var r3 = utils.mapReduce(c, (x) => { return 1 }, (y) => { return new Date() });
|
|
~~~~~
|
|
!!! error TS2454: Variable 'utils' is used before being assigned.
|
|
var r4 = utils.mapReduce(c, (x: string) => { return 1 }, (y: number) => { return new Date() });
|
|
~~~~~
|
|
!!! error TS2454: Variable 'utils' is used before being assigned.
|
|
var f1 = (x: string) => { return 1 };
|
|
var f2 = (y: number) => { return new Date() };
|
|
var r5 = utils.mapReduce(c, f1, f2);
|
|
~~~~~
|
|
!!! error TS2454: Variable 'utils' is used before being assigned.
|
|
|