File: defaultBestCommonTypesHaveDecls.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (56 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download | duplicates (4)
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