40 lines
1.7 KiB
Text
40 lines
1.7 KiB
Text
|
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts(12,9): error TS2346: Supplied parameters do not match any signature of call target.
|
||
|
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts(13,10): error TS2346: Supplied parameters do not match any signature of call target.
|
||
|
|
||
|
|
||
|
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithNonSymmetricSubtypes.ts (2 errors) ====
|
||
|
// generic type argument inference where inference leads to two candidates that are both supertypes of all candidates
|
||
|
// we choose the first candidate so the result is dependent on the order of the arguments provided
|
||
|
|
||
|
function foo<T>(x: T, y: T) {
|
||
|
var r: T;
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
var a: { x: number; y?: number; };
|
||
|
var b: { x: number; z?: number; };
|
||
|
|
||
|
var r = foo(a, b); // { x: number; y?: number; };
|
||
|
~~~~~~~~~
|
||
|
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||
|
var r2 = foo(b, a); // { x: number; z?: number; };
|
||
|
~~~~~~~~~
|
||
|
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||
|
|
||
|
var x: { x: number; };
|
||
|
var y: { x?: number; };
|
||
|
|
||
|
var r3 = foo(a, x); // { x: number; y?: number; };
|
||
|
var r4 = foo(x, a); // { x: number; };
|
||
|
|
||
|
var r5 = foo(a, y); // { x?: number; };
|
||
|
var r5 = foo(y, a); // { x?: number; };
|
||
|
|
||
|
var r6 = foo(x, y); // { x?: number; };
|
||
|
var r6 = foo(y, x); // { x?: number; };
|
||
|
|
||
|
var s1: (x: Object) => string;
|
||
|
var s2: (x: string) => string;
|
||
|
|
||
|
var r7 = foo(s1, s2); // (x: Object) => string;
|
||
|
var r8 = foo(s2, s1); // (x: string) => string;
|