TypeScript/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt
2014-07-24 19:39:50 -07:00

69 lines
2.8 KiB
Plaintext

==== tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts (14 errors) ====
// satisfaction of a constraint to Function, all of these invocations are errors unless otherwise noted
function foo<T extends Function>(x: T): T { return x; }
foo(1);
~
!!! Argument of type 'number' is not assignable to parameter of type 'Function'.
foo(() => { }, 1);
~~~~~~~~~~~~~~~~~
!!! Supplied parameters do not match any signature of call target.
foo(1, () => { });
~~~~~~~~~~~~~~~~~
!!! Supplied parameters do not match any signature of call target.
function foo2<T extends (x: string) => string>(x: T): T { return x; }
class C {
foo: string;
}
var b: { new (x: string): string };
class C2<T> {
foo: T;
}
var b2: { new <T>(x: T): T };
var r = foo2(new Function());
~~~~~~~~~~~~~~
!!! Argument of type 'Function' is not assignable to parameter of type '(x: string) => string'.
var r2 = foo2((x: string[]) => x);
~~~~~~~~~~~~~~~~~~
!!! Argument of type '(x: string[]) => string[]' is not assignable to parameter of type '(x: string) => string'.
var r6 = foo2(C);
~
!!! Argument of type 'typeof C' is not assignable to parameter of type '(x: string) => string'.
var r7 = foo2(b);
~
!!! Argument of type 'new (x: string) => string' is not assignable to parameter of type '(x: string) => string'.
var r8 = foo2(<U>(x: U) => x); // no error expected
var r11 = foo2(<U, V>(x: U, y: V) => x);
~~~~~~~~~~~~~~~~~~~~~~~
!!! Argument of type '<U, V>(x: U, y: V) => U' is not assignable to parameter of type '(x: string) => string'.
var r13 = foo2(C2);
~~
!!! Argument of type 'typeof C2' is not assignable to parameter of type '(x: string) => string'.
var r14 = foo2(b2);
~~
!!! Argument of type 'new <T>(x: T) => T' is not assignable to parameter of type '(x: string) => string'.
interface F2 extends Function { foo: string; }
var f2: F2;
var r16 = foo2(f2);
~~
!!! Argument of type 'F2' is not assignable to parameter of type '(x: string) => string'.
function fff<T extends { (): void }, U extends T>(x: T, y: U) {
~~~~~~~~~~~
!!! Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
foo2(x);
~
!!! Argument of type 'T' is not assignable to parameter of type '(x: string) => string'.
foo2(y);
~
!!! Argument of type 'U' is not assignable to parameter of type '(x: string) => string'.
}