16 lines
No EOL
1.1 KiB
Text
16 lines
No EOL
1.1 KiB
Text
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts(5,9): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
|
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
|
|
|
|
|
|
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectLiteralArgs.ts (1 errors) ====
|
|
function foo<T>(x: { bar: T; baz: T }) {
|
|
return x;
|
|
}
|
|
|
|
var r = foo({ bar: 1, baz: '' }); // error
|
|
~~~
|
|
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
|
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
|
|
var r2 = foo({ bar: 1, baz: 1 }); // T = number
|
|
var r3 = foo({ bar: foo, baz: foo }); // T = typeof foo
|
|
var r4 = foo<Object>({ bar: 1, baz: '' }); // T = Object |