2014-11-05 21:26:03 +01:00
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(14,5): error TS2322: Type 'string' is not assignable to type 'number'.
2014-09-12 22:35:07 +02:00
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(14,37): error TS2345: Argument of type 'D' is not assignable to parameter of type 'A'.
2014-11-05 21:26:03 +01:00
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(16,5): error TS2322: Type 'string' is not assignable to type 'number'.
2014-09-12 22:35:07 +02:00
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(16,38): error TS2344: Type 'D' does not satisfy the constraint 'A'.
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(18,27): error TS2345: Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: B) => any'.
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,12): error TS2344: Type 'D' does not satisfy the constraint 'A'.
2014-07-13 01:04:16 +02:00
==== tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts (6 errors) ====
interface A { x }
interface B { x; y }
interface C { z }
interface D { q }
class G<T extends A> {
constructor(x: T) { }
}
declare function foo(arg: (x: D) => number): string;
declare function foo(arg: (x: C) => any): string;
declare function foo(arg: (x: B) => any): number;
2014-10-22 01:17:37 +02:00
var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked.
2014-07-19 02:30:06 +02:00
~~~~~~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type 'string' is not assignable to type 'number'.
2014-07-25 02:00:03 +02:00
~
2014-09-12 00:19:57 +02:00
!!! error TS2345: Argument of type 'D' is not assignable to parameter of type 'A'.
2014-07-13 01:04:16 +02:00
2014-10-22 01:17:37 +02:00
var result2: number = foo(x => new G<typeof x>(x)); // x has type D, new G(x) fails, so first overload is picked.
~~~~~~~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type 'string' is not assignable to type 'number'.
2014-07-13 01:04:16 +02:00
~~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2344: Type 'D' does not satisfy the constraint 'A'.
2014-07-13 01:04:16 +02:00
2014-10-22 01:17:37 +02:00
var result3: string = foo(x => { // x has type D
~~~~~~~~~~~~~~~~~~~~~~
var y: G<typeof x>; // error that D does not satisfy constraint, y is of type G<D>, entire call to foo is an error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2014-07-13 01:04:16 +02:00
~~~~~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2344: Type 'D' does not satisfy the constraint 'A'.
2014-07-13 01:04:16 +02:00
return y;
~~~~~~~~~~~~~
});
2014-07-25 02:00:03 +02:00
~
2014-09-12 00:19:57 +02:00
!!! error TS2345: Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: B) => any'.
2014-07-13 01:04:16 +02:00