1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
=== tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts ===
var obj1: {};
>obj1 : {}
obj1.length;
>obj1.length : any
>obj1 : {}
>length : any
var obj2: Object;
>obj2 : Object
obj2.length;
>obj2.length : any
>obj2 : Object
>length : any
function concat<T>(x: T, y: T): T { return null; }
>concat : <T>(x: T, y: T) => T
>x : T
>y : T
>null : null
var result = concat(1, ""); // error
>result : number
>concat(1, "") : 1
>concat : <T>(x: T, y: T) => T
>1 : 1
>"" : ""
var elementCount = result.length;
>elementCount : any
>result.length : any
>result : number
>length : any
function concat2<T, U>(x: T, y: U) { return null; }
>concat2 : <T, U>(x: T, y: U) => any
>x : T
>y : U
>null : null
var result2 = concat2(1, ""); // result2 will be number|string
>result2 : any
>concat2(1, "") : any
>concat2 : <T, U>(x: T, y: U) => any
>1 : 1
>"" : ""
var elementCount2 = result.length;
>elementCount2 : any
>result.length : any
>result : number
>length : any
|