-
Notifications
You must be signed in to change notification settings - Fork 12.8k
/
Copy pathassignmentCompatWithCallSignatures4.js
193 lines (177 loc) · 5.77 KB
/
assignmentCompatWithCallSignatures4.js
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
//// [assignmentCompatWithCallSignatures4.ts]
// These are mostly permitted with the current loose rules. All ok unless otherwise noted.
module Errors {
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
module WithNonGenericSignaturesInBaseType {
// target type with non-generic call signatures
var a2: (x: number) => string[];
var a7: (x: (arg: Base) => Derived) => (r: Base) => Derived2;
var a8: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
var a10: (...x: Base[]) => Base;
var a11: (x: { foo: string }, y: { foo: string; bar: string }) => Base;
var a12: (x: Array<Base>, y: Array<Derived2>) => Array<Derived>;
var a14: {
(x: number): number[];
(x: string): string[];
};
var a15: (x: { a: string; b: number }) => number;
var a16: {
(x: {
(a: number): number;
(a?: number): number;
}): number[];
(x: {
(a: boolean): boolean;
(a?: boolean): boolean;
}): boolean[];
};
var a17: {
(x: {
<T extends Derived>(a: T): T;
<T extends Base>(a: T): T;
}): any[];
(x: {
<T extends Derived2>(a: T): T;
<T extends Base>(a: T): T;
}): any[];
};
var b2: <T, U>(x: T) => U[];
a2 = b2;
b2 = a2;
var b7: <T extends Base, U extends Derived, V extends Derived2>(x: (arg: T) => U) => (r: T) => V;
a7 = b7;
b7 = a7;
var b8: <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U;
a8 = b8; // error, { foo: number } and Base are incompatible
b8 = a8; // error, { foo: number } and Base are incompatible
var b10: <T extends Derived>(...x: T[]) => T;
a10 = b10;
b10 = a10;
var b11: <T extends Derived>(x: T, y: T) => T;
a11 = b11;
b11 = a11;
var b12: <T extends Array<Derived2>>(x: Array<Base>, y: Array<Base>) => T;
a12 = b12;
b12 = a12;
var b15: <T>(x: { a: T; b: T }) => T;
a15 = b15;
b15 = a15;
var b15a: <T extends Base>(x: { a: T; b: T }) => number;
a15 = b15a;
b15a = a15;
var b16: <T>(x: (a: T) => T) => T[];
a16 = b16;
b16 = a16;
var b17: <T>(x: (a: T) => T) => any[];
a17 = b17;
b17 = a17;
}
module WithGenericSignaturesInBaseType {
// target type has generic call signature
var a2: <T>(x: T) => T[];
var b2: <T>(x: T) => string[];
a2 = b2;
b2 = a2;
// target type has generic call signature
var a3: <T>(x: T) => string[];
var b3: <T>(x: T) => T[];
a3 = b3;
b3 = a3;
}
}
//// [assignmentCompatWithCallSignatures4.js]
// These are mostly permitted with the current loose rules. All ok unless otherwise noted.
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Errors;
(function (Errors) {
var Base = (function () {
function Base() {
}
return Base;
})();
var Derived = (function (_super) {
__extends(Derived, _super);
function Derived() {
_super.apply(this, arguments);
}
return Derived;
})(Base);
var Derived2 = (function (_super) {
__extends(Derived2, _super);
function Derived2() {
_super.apply(this, arguments);
}
return Derived2;
})(Derived);
var OtherDerived = (function (_super) {
__extends(OtherDerived, _super);
function OtherDerived() {
_super.apply(this, arguments);
}
return OtherDerived;
})(Base);
var WithNonGenericSignaturesInBaseType;
(function (WithNonGenericSignaturesInBaseType) {
// target type with non-generic call signatures
var a2;
var a7;
var a8;
var a10;
var a11;
var a12;
var a14;
var a15;
var a16;
var a17;
var b2;
a2 = b2;
b2 = a2;
var b7;
a7 = b7;
b7 = a7;
var b8;
a8 = b8; // error, { foo: number } and Base are incompatible
b8 = a8; // error, { foo: number } and Base are incompatible
var b10;
a10 = b10;
b10 = a10;
var b11;
a11 = b11;
b11 = a11;
var b12;
a12 = b12;
b12 = a12;
var b15;
a15 = b15;
b15 = a15;
var b15a;
a15 = b15a;
b15a = a15;
var b16;
a16 = b16;
b16 = a16;
var b17;
a17 = b17;
b17 = a17;
})(WithNonGenericSignaturesInBaseType || (WithNonGenericSignaturesInBaseType = {}));
var WithGenericSignaturesInBaseType;
(function (WithGenericSignaturesInBaseType) {
// target type has generic call signature
var a2;
var b2;
a2 = b2;
b2 = a2;
// target type has generic call signature
var a3;
var b3;
a3 = b3;
b3 = a3;
})(WithGenericSignaturesInBaseType || (WithGenericSignaturesInBaseType = {}));
})(Errors || (Errors = {}));