52 lines
2.9 KiB
Plaintext
52 lines
2.9 KiB
Plaintext
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(14,5): error TS2322: Type 'string' is not assignable to type 'number'.
|
|
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(14,37): error TS2345: Argument of type 'D' is not assignable to parameter of type 'A'.
|
|
Property 'x' is missing in type 'D'.
|
|
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(16,5): error TS2322: Type 'string' is not assignable to type 'number'.
|
|
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'.
|
|
Types of parameters 'x' and 'x' are incompatible.
|
|
Type 'D' is not assignable to type 'B'.
|
|
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,12): error TS2344: Type 'D' does not satisfy the constraint 'A'.
|
|
|
|
|
|
==== 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;
|
|
|
|
var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked.
|
|
~~~~~~
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
|
~
|
|
!!! error TS2345: Argument of type 'D' is not assignable to parameter of type 'A'.
|
|
!!! error TS2345: Property 'x' is missing in type 'D'.
|
|
|
|
var result2: number = foo(x => new G<typeof x>(x)); // x has type D, new G(x) fails, so first overload is picked.
|
|
~~~~~~~
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
|
~~~~~~~~
|
|
!!! error TS2344: Type 'D' does not satisfy the constraint 'A'.
|
|
|
|
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
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
~~~~~~~~~~~
|
|
!!! error TS2344: Type 'D' does not satisfy the constraint 'A'.
|
|
return y;
|
|
~~~~~~~~~~~~~
|
|
});
|
|
~
|
|
!!! error TS2345: Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: B) => any'.
|
|
!!! error TS2345: Types of parameters 'x' and 'x' are incompatible.
|
|
!!! error TS2345: Type 'D' is not assignable to type 'B'.
|
|
|