File: implicitAnyGenerics.types

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (80 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
=== tests/cases/compiler/implicitAnyGenerics.ts ===
class C<T> {
>C : C<T>

    x: T;
>x : T
}

var c = new C();
>c : C<{}>
>new C() : C<{}>
>C : typeof C

var c2 = new C<any>();
>c2 : C<any>
>new C<any>() : C<any>
>C : typeof C

var c3 = new C<number>();
>c3 : C<number>
>new C<number>() : C<number>
>C : typeof C

var c4: C<any> = new C();
>c4 : C<any>
>new C() : C<any>
>C : typeof C

class D<T> {
>D : D<T>

    constructor(x: T) { }
>x : T
}

var d = new D(null);
>d : D<any>
>new D(null) : D<any>
>D : typeof D
>null : null

var d2 = new D(1);
>d2 : D<number>
>new D(1) : D<number>
>D : typeof D
>1 : 1

var d3 = new D<any>(1);
>d3 : D<any>
>new D<any>(1) : D<any>
>D : typeof D
>1 : 1

var d4 = new D(<any>1);
>d4 : D<any>
>new D(<any>1) : D<any>
>D : typeof D
><any>1 : any
>1 : 1

var d5: D<any> = new D(null);
>d5 : D<any>
>new D(null) : D<any>
>D : typeof D
>null : null

function foo<T>(): T { return null; };
>foo : <T>() => T
>null : null

foo() 
>foo() : {}
>foo : <T>() => T

foo<any>();
>foo<any>() : any
>foo : <T>() => T