29 lines
No EOL
1.5 KiB
Text
29 lines
No EOL
1.5 KiB
Text
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'.
|
|
|
|
|
|
==== tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts (3 errors) ====
|
|
var obj1: {};
|
|
obj1.length;
|
|
~~~~~~
|
|
!!! error TS2339: Property 'length' does not exist on type '{}'.
|
|
|
|
var obj2: Object;
|
|
obj2.length;
|
|
~~~~~~
|
|
!!! error TS2339: Property 'length' does not exist on type 'Object'.
|
|
|
|
function concat<T>(x: T, y: T): T { return null; }
|
|
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.
|
|
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
|
|
var elementCount = result.length;
|
|
|
|
function concat2<T, U>(x: T, y: U) { return null; }
|
|
var result2 = concat2(1, ""); // result2 will be number|string
|
|
var elementCount2 = result.length;
|
|
|
|
|