1
+ type CssColor = / ^ #( [ 0 - 9 a - f ] { 3 } | [ 0 - 9 a - f ] { 6 } ) $ / i ;
2
+
3
+ type GenericType_0 < T > = Array < T > | T ;
4
+ type GenericType_1 < T extends string > = Array < T > | T ;
5
+ type GenericType_2 < T extends number > = Array < T > | T ;
6
+ let obj_0 : GenericType_0 < CssColor > ;
7
+ if ( obj_0 instanceof Array ) {
8
+ obj_0 . push ( 'nonColor' ) ;
9
+ obj_0 . push ( '#000' ) ;
10
+ } else {
11
+ obj_0 = 'nonColor' ;
12
+ obj_0 = '#000' ;
13
+ }
14
+ let obj_1 : GenericType_1 < CssColor > ;
15
+ if ( obj_1 instanceof Array ) {
16
+ obj_1 . push ( 'nonColor' ) ;
17
+ obj_1 . push ( '#000' ) ;
18
+ } else {
19
+ obj_1 = 'nonColor' ;
20
+ obj_1 = '#000' ;
21
+ }
22
+ let obj_2 : GenericType_2 < CssColor > ;
23
+ if ( obj_2 instanceof Array ) {
24
+ obj_2 . push ( 'nonColor' ) ;
25
+ obj_2 . push ( '#000' ) ;
26
+ } else {
27
+ obj_2 = 'nonColor' ;
28
+ obj_2 = '#000' ;
29
+ }
30
+
31
+ interface GenericInterface_0 < T > {
32
+ property : T ;
33
+ method ( arg : T ) : T ;
34
+ }
35
+ interface GenericInterface_1 < T extends string > {
36
+ property : T ;
37
+ method ( arg : T ) : T ;
38
+ }
39
+ interface GenericInterface_2 < T extends number > {
40
+ property : T ;
41
+ method ( arg : T ) : T ;
42
+ }
43
+ let interface_obj_0 : GenericInterface_0 < CssColor > ;
44
+ interface_obj_0 . property = 'notColor' ;
45
+ interface_obj_0 . property = '#000' ;
46
+ interface_obj_0 . method ( 'notColor' ) ;
47
+ interface_obj_0 . method ( '#000' ) ;
48
+ let interface_obj_1 : GenericInterface_1 < CssColor > ;
49
+ interface_obj_1 . property = 'notColor' ;
50
+ interface_obj_1 . property = '#000' ;
51
+ interface_obj_1 . method ( 'notColor' ) ;
52
+ interface_obj_1 . method ( '#000' ) ;
53
+ let interface_obj_2 : GenericInterface_2 < CssColor > ;
54
+ interface_obj_2 . property = 'notColor' ;
55
+ interface_obj_2 . property = '#000' ;
56
+ interface_obj_2 . method ( 'notColor' ) ;
57
+ interface_obj_2 . method ( '#000' ) ;
58
+
59
+ class GenericClass_0 < T > {
60
+ property : T ;
61
+ constructor ( arg : T ) {
62
+ this . property = arg ;
63
+ }
64
+ method ( arg : T ) : T {
65
+ this . property = arg ;
66
+ return this . property ;
67
+ }
68
+ }
69
+ class GenericClass_1 < T extends string > {
70
+ property : T ;
71
+ constructor ( arg : T ) {
72
+ this . property = arg ;
73
+ }
74
+ method ( arg : T ) : T {
75
+ this . property = arg ;
76
+ return this . property ;
77
+ }
78
+ }
79
+ class GenericClass_2 < T extends number > {
80
+ property : T ;
81
+ constructor ( arg : T ) {
82
+ this . property = arg ;
83
+ }
84
+ method ( arg : T ) : T {
85
+ this . property = arg ;
86
+ return this . property ;
87
+ }
88
+ }
89
+ let class_obj_0 = new GenericClass_0 < CssColor > ( 'notColor' ) ;
90
+ class_obj_0 = new GenericClass_0 < CssColor > ( '#000' ) ;
91
+ class_obj_0 . property = 'notColor' ;
92
+ class_obj_0 . property = '#000' ;
93
+ class_obj_0 . method ( 'notColor' ) ;
94
+ class_obj_0 . method ( '#000' ) ;
95
+ let class_obj_1 = new GenericClass_1 < CssColor > ( 'notColor' ) ;
96
+ class_obj_1 = new GenericClass_1 < CssColor > ( '#000' ) ;
97
+ class_obj_1 . property = 'notColor' ;
98
+ class_obj_1 . property = '#000' ;
99
+ class_obj_1 . method ( 'notColor' ) ;
100
+ class_obj_1 . method ( '#000' ) ;
101
+ let class_obj_2 = new GenericClass_2 < CssColor > ( 'notColor' ) ;
102
+ class_obj_2 = new GenericClass_2 < CssColor > ( '#000' ) ;
103
+ class_obj_2 . property = 'notColor' ;
104
+ class_obj_2 . property = '#000' ;
105
+ class_obj_2 . method ( 'notColor' ) ;
106
+ class_obj_2 . method ( '#000' ) ;
107
+
108
+ class ClassWithGenericMethods {
109
+ genericMethod_0 < T > ( arg : T ) : T {
110
+ return arg ;
111
+ }
112
+ genericMethod_1 < T extends string > ( arg : T ) : T {
113
+ return arg ;
114
+ }
115
+ genericMethod_2 < T extends number > ( arg : T ) : T {
116
+ return arg ;
117
+ }
118
+ }
119
+ let class_obj_3 = new ClassWithGenericMethods ( ) ;
120
+ class_obj_3 . genericMethod_0 < CssColor > ( 'notColor' ) ;
121
+ class_obj_3 . genericMethod_0 < CssColor > ( '#000' ) ;
122
+ class_obj_3 . genericMethod_1 < CssColor > ( 'notColor' ) ;
123
+ class_obj_3 . genericMethod_1 < CssColor > ( '#000' ) ;
124
+ class_obj_3 . genericMethod_2 < CssColor > ( 'notColor' ) ;
125
+ class_obj_3 . genericMethod_2 < CssColor > ( '#000' ) ;
126
+
127
+ function genericFunction_0 < T > ( arg : T ) : T {
128
+ return arg ;
129
+ }
130
+ function genericFunction_1 < T extends string > ( arg : T ) : T {
131
+ return arg ;
132
+ }
133
+ function genericFunction_2 < T extends number > ( arg : T ) : T {
134
+ return arg ;
135
+ }
136
+ genericFunction_0 < CssColor > ( 'notColor' ) ;
137
+ genericFunction_0 < CssColor > ( '#000' ) ;
138
+ genericFunction_1 < CssColor > ( 'notColor' ) ;
139
+ genericFunction_1 < CssColor > ( '#000' ) ;
140
+ genericFunction_2 < CssColor > ( 'notColor' ) ;
141
+ genericFunction_2 < CssColor > ( '#000' ) ;
0 commit comments