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

29 lines
1.5 KiB
Plaintext
Raw Normal View History

2014-10-10 23:41:14 +02:00
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(2,6): error TS2339: Property 'length' does not exist on type '{}'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(5,6): error TS2339: Property 'length' does not exist on type 'Object'.
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(8,14): 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-07-13 01:04:16 +02:00
==== tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts (3 errors) ====
var obj1: {};
obj1.length;
~~~~~~
!!! error TS2339: Property 'length' does not exist on type '{}'.
2014-07-13 01:04:16 +02:00
var obj2: Object;
obj2.length;
~~~~~~
!!! error TS2339: Property 'length' does not exist on type 'Object'.
2014-07-13 01:04:16 +02:00
function concat<T>(x: T, y: T): T { return null; }
2014-10-10 23:41:14 +02:00
var result = concat(1, ""); // 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 elementCount = result.length;
2014-07-13 01:04:16 +02:00
2014-10-10 23:41:14 +02:00
function concat2<T, U>(x: T, y: U) { return null; }
var result2 = concat2(1, ""); // result2 will be number|string
var elementCount2 = result.length;
2014-07-13 01:04:16 +02:00