33 lines
No EOL
1.7 KiB
Text
33 lines
No EOL
1.7 KiB
Text
tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(16,32): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
|
|
Type 'string' is not assignable to type 'Date'.
|
|
Property 'toDateString' is missing in type 'String'.
|
|
tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(17,32): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
|
|
Type 'string' is not assignable to type 'Date'.
|
|
|
|
|
|
==== tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts (2 errors) ====
|
|
interface Collection<T> {
|
|
length: number;
|
|
add(x: T): void;
|
|
remove(x: T): boolean;
|
|
}
|
|
|
|
interface Combinators {
|
|
forEach<T>(c: Collection<T>, f: (x: T) => Date): void;
|
|
}
|
|
|
|
var c2: Collection<number>;
|
|
var _: Combinators;
|
|
|
|
// errors on all 3 lines, bug was that r5 was the only line with errors
|
|
var f = (x: number) => { return x.toFixed() };
|
|
var r5 = _.forEach<number>(c2, f);
|
|
~
|
|
!!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
|
|
!!! error TS2345: Type 'string' is not assignable to type 'Date'.
|
|
!!! error TS2345: Property 'toDateString' is missing in type 'String'.
|
|
var r6 = _.forEach<number>(c2, (x) => { return x.toFixed() });
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
|
|
!!! error TS2345: Type 'string' is not assignable to type 'Date'.
|
|
|