TypeScript/tests/baselines/reference/genericCallWithObjectLiteralArgs.errors.txt

16 lines
1.1 KiB
Plaintext
Raw Normal View History

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'.
2014-10-10 23:41:14 +02:00
==== 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.
2014-10-25 01:42:22 +02:00
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
2014-10-10 23:41:14 +02:00
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