a515b199b7
Fixes #93. This is an evolution of #220.
30 lines
No EOL
1.3 KiB
Text
30 lines
No EOL
1.3 KiB
Text
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstructorTypedArguments5.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: new(t: T) => U }) {
|
|
return new arg.cb(null);
|
|
}
|
|
|
|
var arg: { cb: new<T>(x: T) => string };
|
|
var r = foo(arg); // {}
|
|
// more args not allowed
|
|
var arg2: { cb: new <T>(x: T, y: T) => string };
|
|
var r2 = foo(arg2); // error
|
|
~~~~
|
|
!!! Argument type '{ cb: new <T>(x: T, y: T) => string; }' is not assignable to parameter type '{ cb: new (t: any) => string; }'.
|
|
var arg3: { cb: new (x: string, y: number) => string };
|
|
var r3 = foo(arg3); // error
|
|
~~~~
|
|
!!! Argument type '{ cb: new (x: string, y: number) => string; }' is not assignable to parameter type '{ cb: new (t: string) => string; }'.
|
|
|
|
function foo2<T, U>(arg: { cb: new(t: T, t2: T) => U }) {
|
|
return new arg.cb(null, null);
|
|
}
|
|
|
|
// fewer args ok
|
|
var r4 = foo(arg); // {}
|
|
var arg4: { cb: new (x: string) => string };
|
|
var r6 = foo(arg4); // string
|
|
var arg5: { cb: new () => string };
|
|
var r7 = foo(arg5); // string
|
|
|