File: constraintSatisfactionWithAny.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 (131 lines) | stat: -rw-r--r-- 2,401 bytes parent folder | download | duplicates (5)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
=== tests/cases/conformance/types/typeParameters/typeArgumentLists/constraintSatisfactionWithAny.ts ===
// any is not a valid type argument unless there is no constraint, or the constraint is any

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

function foo2<T extends { x: number }>(x: T): T { return null; }
>foo2 : <T extends { x: number; }>(x: T) => T
>x : number
>x : T
>null : null

//function foo3<T extends T[]>(x: T): T { return null; }
function foo4<T extends <T>(x: T) => void>(x: T): T { return null; }
>foo4 : <T extends <T>(x: T) => void>(x: T) => T
>x : T
>x : T
>null : null

var a;
>a : any

foo(a);
>foo(a) : any
>foo : <T extends String>(x: T) => T
>a : any

foo2(a);
>foo2(a) : any
>foo2 : <T extends { x: number; }>(x: T) => T
>a : any

//foo3(a);
foo4(a);
>foo4(a) : any
>foo4 : <T extends <T>(x: T) => void>(x: T) => T
>a : any

var b: number;
>b : number

foo<any>(b);
>foo<any>(b) : any
>foo : <T extends String>(x: T) => T
>b : number

foo2<any>(b);
>foo2<any>(b) : any
>foo2 : <T extends { x: number; }>(x: T) => T
>b : number

//foo3<any>(b);
foo4<any>(b);
>foo4<any>(b) : any
>foo4 : <T extends <T>(x: T) => void>(x: T) => T
>b : number

//function foo5<T extends String, U extends T>(x: T, y: U): T { return null; }
//foo5(a, a);
//foo5<any, any>(b, b);

class C<T extends String> {
>C : C<T>

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

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

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

class C2<T extends { x: number }> {
>C2 : C2<T>
>x : number

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

var c3 = new C2(a);
>c3 : C2<any>
>new C2(a) : C2<any>
>C2 : typeof C2
>a : any

var c4 = new C2<any>(b);
>c4 : C2<any>
>new C2<any>(b) : C2<any>
>C2 : typeof C2
>b : number

//class C3<T extends T[]> {
//    constructor(public x: T) { }
//}

//var c5 = new C3(a);
//var c6 = new C3<any>(b);

class C4<T extends <T>(x:T) => T> {
>C4 : C4<T>
>x : T

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

var c7 = new C4(a);
>c7 : C4<any>
>new C4(a) : C4<any>
>C4 : typeof C4
>a : any

var c8 = new C4<any>(b);
>c8 : C4<any>
>new C4<any>(b) : C4<any>
>C4 : typeof C4
>b : number