TypeScript/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt
Daniel Rosenwasser 6e77e2e810 Removed colons from diagnostic messages.
Also got rid of the 'terminalMessages' concept.
2014-10-28 00:48:58 -07:00

39 lines
2.4 KiB
Plaintext

tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(10,14): error TS2345: Argument of type '{ cb: <T>(x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'.
Types of property 'cb' are incompatible.
Type '<T>(x: T, y: T) => string' is not assignable to type '(t: {}) => string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(11,14): error TS2345: Argument of type '{ cb: (x: string, y: number) => string; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'.
Types of property 'cb' are incompatible.
Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts (2 errors) ====
// Generic call with parameter of object type with member of function type of n args passed object whose associated member is call signature with n+1 args
function foo<T, U>(arg: { cb: (t: T) => U }) {
return arg.cb(null);
}
var arg = { cb: <T>(x: T) => '' };
var r = foo(arg); // {}
// more args not allowed
var r2 = foo({ cb: <T>(x: T, y: T) => '' }); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ cb: <T>(x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'.
!!! error TS2345: Types of property 'cb' are incompatible.
!!! error TS2345: Type '<T>(x: T, y: T) => string' is not assignable to type '(t: {}) => string'.
var r3 = foo({ cb: (x: string, y: number) => '' }); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ cb: (x: string, y: number) => string; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'.
!!! error TS2345: Types of property 'cb' are incompatible.
!!! error TS2345: Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'.
function foo2<T, U>(arg: { cb: (t: T, t2: T) => U }) {
return arg.cb(null, null);
}
// fewer args ok
var r4 = foo(arg); // {}
var r5 = foo({ cb: <T>(x: T) => '' }); // {}
var r6 = foo({ cb: (x: string) => '' }); // string
var r7 = foo({ cb: () => '' }); // string