@angular/core 19.0.0-rc.1 → 19.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/core.mjs +13164 -13060
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +2 -2
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +4 -4
- package/index.d.ts +74 -13
- package/package.json +1 -1
- package/primitives/event-dispatch/index.d.ts +1 -1
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/bundles/{checker-9ca42e51.js → checker-e3da3b0a.js} +95 -54
- package/schematics/bundles/{combine_units-a16385aa.js → combine_units-2adebceb.js} +97 -28
- package/schematics/bundles/{compiler_host-31afa4ed.js → compiler_host-d642e87e.js} +2 -2
- package/schematics/bundles/control-flow-migration.js +3 -3
- package/schematics/bundles/explicit-standalone-flag.js +3 -3
- package/schematics/bundles/imports-4ac08251.js +1 -1
- package/schematics/bundles/inject-migration.js +3 -3
- package/schematics/bundles/leading_space-d190b83b.js +1 -1
- package/schematics/bundles/{migrate_ts_type_references-b2a28742.js → migrate_ts_type_references-ed2c0669.js} +527 -31
- package/schematics/bundles/nodes-0e7d45ca.js +1 -1
- package/schematics/bundles/output-migration.js +17 -14
- package/schematics/bundles/pending-tasks.js +3 -3
- package/schematics/bundles/{program-71beec0b.js → program-f984ab63.js} +45 -52
- package/schematics/bundles/project_tsconfig_paths-e9ccccbf.js +1 -1
- package/schematics/bundles/provide-initializer.js +3 -3
- package/schematics/bundles/route-lazy-loading.js +3 -3
- package/schematics/bundles/signal-input-migration.js +48 -35
- package/schematics/bundles/signal-queries-migration.js +21 -14
- package/schematics/bundles/signals.js +5 -5
- package/schematics/bundles/standalone-migration.js +159 -75
- package/schematics/ng-generate/signals/schema.json +1 -0
- package/testing/index.d.ts +1 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.0.0-rc.
|
|
3
|
+
* @license Angular v19.0.0-rc.3
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
var checker = require('./checker-
|
|
9
|
+
var checker = require('./checker-e3da3b0a.js');
|
|
10
10
|
var ts = require('typescript');
|
|
11
11
|
require('os');
|
|
12
12
|
var assert = require('assert');
|
|
13
|
-
var combine_units = require('./combine_units-
|
|
13
|
+
var combine_units = require('./combine_units-2adebceb.js');
|
|
14
14
|
var leading_space = require('./leading_space-d190b83b.js');
|
|
15
|
-
require('./program-
|
|
15
|
+
require('./program-f984ab63.js');
|
|
16
16
|
require('path');
|
|
17
17
|
|
|
18
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -80,6 +80,467 @@ function pickFieldIncompatibility(a, b) {
|
|
|
80
80
|
return a;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* A lazily created TextEncoder instance for converting strings into UTF-8 bytes
|
|
85
|
+
*/
|
|
86
|
+
// Utils
|
|
87
|
+
var Endian;
|
|
88
|
+
(function (Endian) {
|
|
89
|
+
Endian[Endian["Little"] = 0] = "Little";
|
|
90
|
+
Endian[Endian["Big"] = 1] = "Big";
|
|
91
|
+
})(Endian || (Endian = {}));
|
|
92
|
+
|
|
93
|
+
//// Types
|
|
94
|
+
var TypeModifier;
|
|
95
|
+
(function (TypeModifier) {
|
|
96
|
+
TypeModifier[TypeModifier["None"] = 0] = "None";
|
|
97
|
+
TypeModifier[TypeModifier["Const"] = 1] = "Const";
|
|
98
|
+
})(TypeModifier || (TypeModifier = {}));
|
|
99
|
+
class Type {
|
|
100
|
+
modifiers;
|
|
101
|
+
constructor(modifiers = TypeModifier.None) {
|
|
102
|
+
this.modifiers = modifiers;
|
|
103
|
+
}
|
|
104
|
+
hasModifier(modifier) {
|
|
105
|
+
return (this.modifiers & modifier) !== 0;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
var BuiltinTypeName;
|
|
109
|
+
(function (BuiltinTypeName) {
|
|
110
|
+
BuiltinTypeName[BuiltinTypeName["Dynamic"] = 0] = "Dynamic";
|
|
111
|
+
BuiltinTypeName[BuiltinTypeName["Bool"] = 1] = "Bool";
|
|
112
|
+
BuiltinTypeName[BuiltinTypeName["String"] = 2] = "String";
|
|
113
|
+
BuiltinTypeName[BuiltinTypeName["Int"] = 3] = "Int";
|
|
114
|
+
BuiltinTypeName[BuiltinTypeName["Number"] = 4] = "Number";
|
|
115
|
+
BuiltinTypeName[BuiltinTypeName["Function"] = 5] = "Function";
|
|
116
|
+
BuiltinTypeName[BuiltinTypeName["Inferred"] = 6] = "Inferred";
|
|
117
|
+
BuiltinTypeName[BuiltinTypeName["None"] = 7] = "None";
|
|
118
|
+
})(BuiltinTypeName || (BuiltinTypeName = {}));
|
|
119
|
+
class BuiltinType extends Type {
|
|
120
|
+
name;
|
|
121
|
+
constructor(name, modifiers) {
|
|
122
|
+
super(modifiers);
|
|
123
|
+
this.name = name;
|
|
124
|
+
}
|
|
125
|
+
visitType(visitor, context) {
|
|
126
|
+
return visitor.visitBuiltinType(this, context);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
new BuiltinType(BuiltinTypeName.Dynamic);
|
|
130
|
+
const INFERRED_TYPE = new BuiltinType(BuiltinTypeName.Inferred);
|
|
131
|
+
new BuiltinType(BuiltinTypeName.Bool);
|
|
132
|
+
new BuiltinType(BuiltinTypeName.Int);
|
|
133
|
+
new BuiltinType(BuiltinTypeName.Number);
|
|
134
|
+
new BuiltinType(BuiltinTypeName.String);
|
|
135
|
+
new BuiltinType(BuiltinTypeName.Function);
|
|
136
|
+
new BuiltinType(BuiltinTypeName.None);
|
|
137
|
+
///// Expressions
|
|
138
|
+
var UnaryOperator;
|
|
139
|
+
(function (UnaryOperator) {
|
|
140
|
+
UnaryOperator[UnaryOperator["Minus"] = 0] = "Minus";
|
|
141
|
+
UnaryOperator[UnaryOperator["Plus"] = 1] = "Plus";
|
|
142
|
+
})(UnaryOperator || (UnaryOperator = {}));
|
|
143
|
+
var BinaryOperator;
|
|
144
|
+
(function (BinaryOperator) {
|
|
145
|
+
BinaryOperator[BinaryOperator["Equals"] = 0] = "Equals";
|
|
146
|
+
BinaryOperator[BinaryOperator["NotEquals"] = 1] = "NotEquals";
|
|
147
|
+
BinaryOperator[BinaryOperator["Identical"] = 2] = "Identical";
|
|
148
|
+
BinaryOperator[BinaryOperator["NotIdentical"] = 3] = "NotIdentical";
|
|
149
|
+
BinaryOperator[BinaryOperator["Minus"] = 4] = "Minus";
|
|
150
|
+
BinaryOperator[BinaryOperator["Plus"] = 5] = "Plus";
|
|
151
|
+
BinaryOperator[BinaryOperator["Divide"] = 6] = "Divide";
|
|
152
|
+
BinaryOperator[BinaryOperator["Multiply"] = 7] = "Multiply";
|
|
153
|
+
BinaryOperator[BinaryOperator["Modulo"] = 8] = "Modulo";
|
|
154
|
+
BinaryOperator[BinaryOperator["And"] = 9] = "And";
|
|
155
|
+
BinaryOperator[BinaryOperator["Or"] = 10] = "Or";
|
|
156
|
+
BinaryOperator[BinaryOperator["BitwiseOr"] = 11] = "BitwiseOr";
|
|
157
|
+
BinaryOperator[BinaryOperator["BitwiseAnd"] = 12] = "BitwiseAnd";
|
|
158
|
+
BinaryOperator[BinaryOperator["Lower"] = 13] = "Lower";
|
|
159
|
+
BinaryOperator[BinaryOperator["LowerEquals"] = 14] = "LowerEquals";
|
|
160
|
+
BinaryOperator[BinaryOperator["Bigger"] = 15] = "Bigger";
|
|
161
|
+
BinaryOperator[BinaryOperator["BiggerEquals"] = 16] = "BiggerEquals";
|
|
162
|
+
BinaryOperator[BinaryOperator["NullishCoalesce"] = 17] = "NullishCoalesce";
|
|
163
|
+
})(BinaryOperator || (BinaryOperator = {}));
|
|
164
|
+
function nullSafeIsEquivalent(base, other) {
|
|
165
|
+
if (base == null || other == null) {
|
|
166
|
+
return base == other;
|
|
167
|
+
}
|
|
168
|
+
return base.isEquivalent(other);
|
|
169
|
+
}
|
|
170
|
+
function areAllEquivalentPredicate(base, other, equivalentPredicate) {
|
|
171
|
+
const len = base.length;
|
|
172
|
+
if (len !== other.length) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
for (let i = 0; i < len; i++) {
|
|
176
|
+
if (!equivalentPredicate(base[i], other[i])) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
function areAllEquivalent(base, other) {
|
|
183
|
+
return areAllEquivalentPredicate(base, other, (baseElement, otherElement) => baseElement.isEquivalent(otherElement));
|
|
184
|
+
}
|
|
185
|
+
class Expression {
|
|
186
|
+
type;
|
|
187
|
+
sourceSpan;
|
|
188
|
+
constructor(type, sourceSpan) {
|
|
189
|
+
this.type = type || null;
|
|
190
|
+
this.sourceSpan = sourceSpan || null;
|
|
191
|
+
}
|
|
192
|
+
prop(name, sourceSpan) {
|
|
193
|
+
return new ReadPropExpr(this, name, null, sourceSpan);
|
|
194
|
+
}
|
|
195
|
+
key(index, type, sourceSpan) {
|
|
196
|
+
return new ReadKeyExpr(this, index, type, sourceSpan);
|
|
197
|
+
}
|
|
198
|
+
callFn(params, sourceSpan, pure) {
|
|
199
|
+
return new InvokeFunctionExpr(this, params, null, sourceSpan, pure);
|
|
200
|
+
}
|
|
201
|
+
instantiate(params, type, sourceSpan) {
|
|
202
|
+
return new InstantiateExpr(this, params, type, sourceSpan);
|
|
203
|
+
}
|
|
204
|
+
conditional(trueCase, falseCase = null, sourceSpan) {
|
|
205
|
+
return new ConditionalExpr(this, trueCase, falseCase, null, sourceSpan);
|
|
206
|
+
}
|
|
207
|
+
equals(rhs, sourceSpan) {
|
|
208
|
+
return new BinaryOperatorExpr(BinaryOperator.Equals, this, rhs, null, sourceSpan);
|
|
209
|
+
}
|
|
210
|
+
notEquals(rhs, sourceSpan) {
|
|
211
|
+
return new BinaryOperatorExpr(BinaryOperator.NotEquals, this, rhs, null, sourceSpan);
|
|
212
|
+
}
|
|
213
|
+
identical(rhs, sourceSpan) {
|
|
214
|
+
return new BinaryOperatorExpr(BinaryOperator.Identical, this, rhs, null, sourceSpan);
|
|
215
|
+
}
|
|
216
|
+
notIdentical(rhs, sourceSpan) {
|
|
217
|
+
return new BinaryOperatorExpr(BinaryOperator.NotIdentical, this, rhs, null, sourceSpan);
|
|
218
|
+
}
|
|
219
|
+
minus(rhs, sourceSpan) {
|
|
220
|
+
return new BinaryOperatorExpr(BinaryOperator.Minus, this, rhs, null, sourceSpan);
|
|
221
|
+
}
|
|
222
|
+
plus(rhs, sourceSpan) {
|
|
223
|
+
return new BinaryOperatorExpr(BinaryOperator.Plus, this, rhs, null, sourceSpan);
|
|
224
|
+
}
|
|
225
|
+
divide(rhs, sourceSpan) {
|
|
226
|
+
return new BinaryOperatorExpr(BinaryOperator.Divide, this, rhs, null, sourceSpan);
|
|
227
|
+
}
|
|
228
|
+
multiply(rhs, sourceSpan) {
|
|
229
|
+
return new BinaryOperatorExpr(BinaryOperator.Multiply, this, rhs, null, sourceSpan);
|
|
230
|
+
}
|
|
231
|
+
modulo(rhs, sourceSpan) {
|
|
232
|
+
return new BinaryOperatorExpr(BinaryOperator.Modulo, this, rhs, null, sourceSpan);
|
|
233
|
+
}
|
|
234
|
+
and(rhs, sourceSpan) {
|
|
235
|
+
return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan);
|
|
236
|
+
}
|
|
237
|
+
bitwiseOr(rhs, sourceSpan, parens = true) {
|
|
238
|
+
return new BinaryOperatorExpr(BinaryOperator.BitwiseOr, this, rhs, null, sourceSpan, parens);
|
|
239
|
+
}
|
|
240
|
+
bitwiseAnd(rhs, sourceSpan, parens = true) {
|
|
241
|
+
return new BinaryOperatorExpr(BinaryOperator.BitwiseAnd, this, rhs, null, sourceSpan, parens);
|
|
242
|
+
}
|
|
243
|
+
or(rhs, sourceSpan) {
|
|
244
|
+
return new BinaryOperatorExpr(BinaryOperator.Or, this, rhs, null, sourceSpan);
|
|
245
|
+
}
|
|
246
|
+
lower(rhs, sourceSpan) {
|
|
247
|
+
return new BinaryOperatorExpr(BinaryOperator.Lower, this, rhs, null, sourceSpan);
|
|
248
|
+
}
|
|
249
|
+
lowerEquals(rhs, sourceSpan) {
|
|
250
|
+
return new BinaryOperatorExpr(BinaryOperator.LowerEquals, this, rhs, null, sourceSpan);
|
|
251
|
+
}
|
|
252
|
+
bigger(rhs, sourceSpan) {
|
|
253
|
+
return new BinaryOperatorExpr(BinaryOperator.Bigger, this, rhs, null, sourceSpan);
|
|
254
|
+
}
|
|
255
|
+
biggerEquals(rhs, sourceSpan) {
|
|
256
|
+
return new BinaryOperatorExpr(BinaryOperator.BiggerEquals, this, rhs, null, sourceSpan);
|
|
257
|
+
}
|
|
258
|
+
isBlank(sourceSpan) {
|
|
259
|
+
// Note: We use equals by purpose here to compare to null and undefined in JS.
|
|
260
|
+
// We use the typed null to allow strictNullChecks to narrow types.
|
|
261
|
+
return this.equals(TYPED_NULL_EXPR, sourceSpan);
|
|
262
|
+
}
|
|
263
|
+
nullishCoalesce(rhs, sourceSpan) {
|
|
264
|
+
return new BinaryOperatorExpr(BinaryOperator.NullishCoalesce, this, rhs, null, sourceSpan);
|
|
265
|
+
}
|
|
266
|
+
toStmt() {
|
|
267
|
+
return new ExpressionStatement(this, null);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
class WriteKeyExpr extends Expression {
|
|
271
|
+
receiver;
|
|
272
|
+
index;
|
|
273
|
+
value;
|
|
274
|
+
constructor(receiver, index, value, type, sourceSpan) {
|
|
275
|
+
super(type || value.type, sourceSpan);
|
|
276
|
+
this.receiver = receiver;
|
|
277
|
+
this.index = index;
|
|
278
|
+
this.value = value;
|
|
279
|
+
}
|
|
280
|
+
isEquivalent(e) {
|
|
281
|
+
return (e instanceof WriteKeyExpr &&
|
|
282
|
+
this.receiver.isEquivalent(e.receiver) &&
|
|
283
|
+
this.index.isEquivalent(e.index) &&
|
|
284
|
+
this.value.isEquivalent(e.value));
|
|
285
|
+
}
|
|
286
|
+
isConstant() {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
visitExpression(visitor, context) {
|
|
290
|
+
return visitor.visitWriteKeyExpr(this, context);
|
|
291
|
+
}
|
|
292
|
+
clone() {
|
|
293
|
+
return new WriteKeyExpr(this.receiver.clone(), this.index.clone(), this.value.clone(), this.type, this.sourceSpan);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
class WritePropExpr extends Expression {
|
|
297
|
+
receiver;
|
|
298
|
+
name;
|
|
299
|
+
value;
|
|
300
|
+
constructor(receiver, name, value, type, sourceSpan) {
|
|
301
|
+
super(type || value.type, sourceSpan);
|
|
302
|
+
this.receiver = receiver;
|
|
303
|
+
this.name = name;
|
|
304
|
+
this.value = value;
|
|
305
|
+
}
|
|
306
|
+
isEquivalent(e) {
|
|
307
|
+
return (e instanceof WritePropExpr &&
|
|
308
|
+
this.receiver.isEquivalent(e.receiver) &&
|
|
309
|
+
this.name === e.name &&
|
|
310
|
+
this.value.isEquivalent(e.value));
|
|
311
|
+
}
|
|
312
|
+
isConstant() {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
visitExpression(visitor, context) {
|
|
316
|
+
return visitor.visitWritePropExpr(this, context);
|
|
317
|
+
}
|
|
318
|
+
clone() {
|
|
319
|
+
return new WritePropExpr(this.receiver.clone(), this.name, this.value.clone(), this.type, this.sourceSpan);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
class InvokeFunctionExpr extends Expression {
|
|
323
|
+
fn;
|
|
324
|
+
args;
|
|
325
|
+
pure;
|
|
326
|
+
constructor(fn, args, type, sourceSpan, pure = false) {
|
|
327
|
+
super(type, sourceSpan);
|
|
328
|
+
this.fn = fn;
|
|
329
|
+
this.args = args;
|
|
330
|
+
this.pure = pure;
|
|
331
|
+
}
|
|
332
|
+
// An alias for fn, which allows other logic to handle calls and property reads together.
|
|
333
|
+
get receiver() {
|
|
334
|
+
return this.fn;
|
|
335
|
+
}
|
|
336
|
+
isEquivalent(e) {
|
|
337
|
+
return (e instanceof InvokeFunctionExpr &&
|
|
338
|
+
this.fn.isEquivalent(e.fn) &&
|
|
339
|
+
areAllEquivalent(this.args, e.args) &&
|
|
340
|
+
this.pure === e.pure);
|
|
341
|
+
}
|
|
342
|
+
isConstant() {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
visitExpression(visitor, context) {
|
|
346
|
+
return visitor.visitInvokeFunctionExpr(this, context);
|
|
347
|
+
}
|
|
348
|
+
clone() {
|
|
349
|
+
return new InvokeFunctionExpr(this.fn.clone(), this.args.map((arg) => arg.clone()), this.type, this.sourceSpan, this.pure);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
class InstantiateExpr extends Expression {
|
|
353
|
+
classExpr;
|
|
354
|
+
args;
|
|
355
|
+
constructor(classExpr, args, type, sourceSpan) {
|
|
356
|
+
super(type, sourceSpan);
|
|
357
|
+
this.classExpr = classExpr;
|
|
358
|
+
this.args = args;
|
|
359
|
+
}
|
|
360
|
+
isEquivalent(e) {
|
|
361
|
+
return (e instanceof InstantiateExpr &&
|
|
362
|
+
this.classExpr.isEquivalent(e.classExpr) &&
|
|
363
|
+
areAllEquivalent(this.args, e.args));
|
|
364
|
+
}
|
|
365
|
+
isConstant() {
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
visitExpression(visitor, context) {
|
|
369
|
+
return visitor.visitInstantiateExpr(this, context);
|
|
370
|
+
}
|
|
371
|
+
clone() {
|
|
372
|
+
return new InstantiateExpr(this.classExpr.clone(), this.args.map((arg) => arg.clone()), this.type, this.sourceSpan);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
class LiteralExpr extends Expression {
|
|
376
|
+
value;
|
|
377
|
+
constructor(value, type, sourceSpan) {
|
|
378
|
+
super(type, sourceSpan);
|
|
379
|
+
this.value = value;
|
|
380
|
+
}
|
|
381
|
+
isEquivalent(e) {
|
|
382
|
+
return e instanceof LiteralExpr && this.value === e.value;
|
|
383
|
+
}
|
|
384
|
+
isConstant() {
|
|
385
|
+
return true;
|
|
386
|
+
}
|
|
387
|
+
visitExpression(visitor, context) {
|
|
388
|
+
return visitor.visitLiteralExpr(this, context);
|
|
389
|
+
}
|
|
390
|
+
clone() {
|
|
391
|
+
return new LiteralExpr(this.value, this.type, this.sourceSpan);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
class ConditionalExpr extends Expression {
|
|
395
|
+
condition;
|
|
396
|
+
falseCase;
|
|
397
|
+
trueCase;
|
|
398
|
+
constructor(condition, trueCase, falseCase = null, type, sourceSpan) {
|
|
399
|
+
super(type || trueCase.type, sourceSpan);
|
|
400
|
+
this.condition = condition;
|
|
401
|
+
this.falseCase = falseCase;
|
|
402
|
+
this.trueCase = trueCase;
|
|
403
|
+
}
|
|
404
|
+
isEquivalent(e) {
|
|
405
|
+
return (e instanceof ConditionalExpr &&
|
|
406
|
+
this.condition.isEquivalent(e.condition) &&
|
|
407
|
+
this.trueCase.isEquivalent(e.trueCase) &&
|
|
408
|
+
nullSafeIsEquivalent(this.falseCase, e.falseCase));
|
|
409
|
+
}
|
|
410
|
+
isConstant() {
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
visitExpression(visitor, context) {
|
|
414
|
+
return visitor.visitConditionalExpr(this, context);
|
|
415
|
+
}
|
|
416
|
+
clone() {
|
|
417
|
+
return new ConditionalExpr(this.condition.clone(), this.trueCase.clone(), this.falseCase?.clone(), this.type, this.sourceSpan);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
class BinaryOperatorExpr extends Expression {
|
|
421
|
+
operator;
|
|
422
|
+
rhs;
|
|
423
|
+
parens;
|
|
424
|
+
lhs;
|
|
425
|
+
constructor(operator, lhs, rhs, type, sourceSpan, parens = true) {
|
|
426
|
+
super(type || lhs.type, sourceSpan);
|
|
427
|
+
this.operator = operator;
|
|
428
|
+
this.rhs = rhs;
|
|
429
|
+
this.parens = parens;
|
|
430
|
+
this.lhs = lhs;
|
|
431
|
+
}
|
|
432
|
+
isEquivalent(e) {
|
|
433
|
+
return (e instanceof BinaryOperatorExpr &&
|
|
434
|
+
this.operator === e.operator &&
|
|
435
|
+
this.lhs.isEquivalent(e.lhs) &&
|
|
436
|
+
this.rhs.isEquivalent(e.rhs));
|
|
437
|
+
}
|
|
438
|
+
isConstant() {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
visitExpression(visitor, context) {
|
|
442
|
+
return visitor.visitBinaryOperatorExpr(this, context);
|
|
443
|
+
}
|
|
444
|
+
clone() {
|
|
445
|
+
return new BinaryOperatorExpr(this.operator, this.lhs.clone(), this.rhs.clone(), this.type, this.sourceSpan, this.parens);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
class ReadPropExpr extends Expression {
|
|
449
|
+
receiver;
|
|
450
|
+
name;
|
|
451
|
+
constructor(receiver, name, type, sourceSpan) {
|
|
452
|
+
super(type, sourceSpan);
|
|
453
|
+
this.receiver = receiver;
|
|
454
|
+
this.name = name;
|
|
455
|
+
}
|
|
456
|
+
// An alias for name, which allows other logic to handle property reads and keyed reads together.
|
|
457
|
+
get index() {
|
|
458
|
+
return this.name;
|
|
459
|
+
}
|
|
460
|
+
isEquivalent(e) {
|
|
461
|
+
return (e instanceof ReadPropExpr && this.receiver.isEquivalent(e.receiver) && this.name === e.name);
|
|
462
|
+
}
|
|
463
|
+
isConstant() {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
visitExpression(visitor, context) {
|
|
467
|
+
return visitor.visitReadPropExpr(this, context);
|
|
468
|
+
}
|
|
469
|
+
set(value) {
|
|
470
|
+
return new WritePropExpr(this.receiver, this.name, value, null, this.sourceSpan);
|
|
471
|
+
}
|
|
472
|
+
clone() {
|
|
473
|
+
return new ReadPropExpr(this.receiver.clone(), this.name, this.type, this.sourceSpan);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
class ReadKeyExpr extends Expression {
|
|
477
|
+
receiver;
|
|
478
|
+
index;
|
|
479
|
+
constructor(receiver, index, type, sourceSpan) {
|
|
480
|
+
super(type, sourceSpan);
|
|
481
|
+
this.receiver = receiver;
|
|
482
|
+
this.index = index;
|
|
483
|
+
}
|
|
484
|
+
isEquivalent(e) {
|
|
485
|
+
return (e instanceof ReadKeyExpr &&
|
|
486
|
+
this.receiver.isEquivalent(e.receiver) &&
|
|
487
|
+
this.index.isEquivalent(e.index));
|
|
488
|
+
}
|
|
489
|
+
isConstant() {
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
visitExpression(visitor, context) {
|
|
493
|
+
return visitor.visitReadKeyExpr(this, context);
|
|
494
|
+
}
|
|
495
|
+
set(value) {
|
|
496
|
+
return new WriteKeyExpr(this.receiver, this.index, value, null, this.sourceSpan);
|
|
497
|
+
}
|
|
498
|
+
clone() {
|
|
499
|
+
return new ReadKeyExpr(this.receiver.clone(), this.index.clone(), this.type, this.sourceSpan);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
const NULL_EXPR = new LiteralExpr(null, null, null);
|
|
503
|
+
const TYPED_NULL_EXPR = new LiteralExpr(null, INFERRED_TYPE, null);
|
|
504
|
+
//// Statements
|
|
505
|
+
var StmtModifier;
|
|
506
|
+
(function (StmtModifier) {
|
|
507
|
+
StmtModifier[StmtModifier["None"] = 0] = "None";
|
|
508
|
+
StmtModifier[StmtModifier["Final"] = 1] = "Final";
|
|
509
|
+
StmtModifier[StmtModifier["Private"] = 2] = "Private";
|
|
510
|
+
StmtModifier[StmtModifier["Exported"] = 4] = "Exported";
|
|
511
|
+
StmtModifier[StmtModifier["Static"] = 8] = "Static";
|
|
512
|
+
})(StmtModifier || (StmtModifier = {}));
|
|
513
|
+
class Statement {
|
|
514
|
+
modifiers;
|
|
515
|
+
sourceSpan;
|
|
516
|
+
leadingComments;
|
|
517
|
+
constructor(modifiers = StmtModifier.None, sourceSpan = null, leadingComments) {
|
|
518
|
+
this.modifiers = modifiers;
|
|
519
|
+
this.sourceSpan = sourceSpan;
|
|
520
|
+
this.leadingComments = leadingComments;
|
|
521
|
+
}
|
|
522
|
+
hasModifier(modifier) {
|
|
523
|
+
return (this.modifiers & modifier) !== 0;
|
|
524
|
+
}
|
|
525
|
+
addLeadingComment(leadingComment) {
|
|
526
|
+
this.leadingComments = this.leadingComments ?? [];
|
|
527
|
+
this.leadingComments.push(leadingComment);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
class ExpressionStatement extends Statement {
|
|
531
|
+
expr;
|
|
532
|
+
constructor(expr, sourceSpan, leadingComments) {
|
|
533
|
+
super(StmtModifier.None, sourceSpan, leadingComments);
|
|
534
|
+
this.expr = expr;
|
|
535
|
+
}
|
|
536
|
+
isEquivalent(stmt) {
|
|
537
|
+
return stmt instanceof ExpressionStatement && this.expr.isEquivalent(stmt.expr);
|
|
538
|
+
}
|
|
539
|
+
visitStatement(visitor, context) {
|
|
540
|
+
return visitor.visitExpressionStmt(this, context);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
83
544
|
/**
|
|
84
545
|
* Detects `spyOn(dirInstance, 'myInput')` calls that likely modify
|
|
85
546
|
* the input signal. There is no way to change the value inside the input signal,
|
|
@@ -380,16 +841,18 @@ function checkInheritanceOfKnownFields(inheritanceGraph, metaRegistry, fields, o
|
|
|
380
841
|
// not change again, at a later time.
|
|
381
842
|
assert__default["default"](ts__default["default"].isClassDeclaration(inputClass), 'Expected input graph node to be always a class.');
|
|
382
843
|
const classFields = opts.getFieldsForClass(inputClass);
|
|
844
|
+
const inputFieldNamesFromMetadataArray = new Set();
|
|
383
845
|
// Iterate through derived class chains and determine all inputs that are overridden
|
|
384
846
|
// via class metadata fields. e.g `@Component#inputs`. This is later used to mark a
|
|
385
847
|
// potential similar class input as incompatible— because those cannot be migrated.
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
848
|
+
if (metaRegistry !== null) {
|
|
849
|
+
for (const derivedClasses of inheritanceGraph.traceDerivedClasses(inputClass)) {
|
|
850
|
+
const derivedMeta = ts__default["default"].isClassDeclaration(derivedClasses) && derivedClasses.name !== undefined
|
|
851
|
+
? metaRegistry.getDirectiveMetadata(new checker.Reference(derivedClasses))
|
|
852
|
+
: null;
|
|
853
|
+
if (derivedMeta !== null && derivedMeta.inputFieldNamesFromMetadataArray !== null) {
|
|
854
|
+
derivedMeta.inputFieldNamesFromMetadataArray.forEach((b) => inputFieldNamesFromMetadataArray.add(b));
|
|
855
|
+
}
|
|
393
856
|
}
|
|
394
857
|
}
|
|
395
858
|
// Check inheritance of every input in the given "directive class".
|
|
@@ -515,7 +978,7 @@ function getMessageForFieldIncompatibility(reason, fieldName) {
|
|
|
515
978
|
return {
|
|
516
979
|
short: `This ${fieldName.single} is used in combination with \`@HostBinding\` and ` +
|
|
517
980
|
`migrating would break.`,
|
|
518
|
-
extra: `\`@HostBinding\` does not invoke the signal automatically and your code would
|
|
981
|
+
extra: `\`@HostBinding\` does not invoke the signal automatically and your code would ` +
|
|
519
982
|
`break after migration. Use \`host\` of \`@Directive\`/\`@Component\`for host bindings.`,
|
|
520
983
|
};
|
|
521
984
|
case exports.FieldIncompatibilityReason.PotentiallyNarrowedInTemplateButNoSupportYet:
|
|
@@ -595,7 +1058,7 @@ function getMessageForClassIncompatibility(reason, fieldName) {
|
|
|
595
1058
|
case exports.ClassIncompatibilityReason.ClassManuallyInstantiated:
|
|
596
1059
|
return {
|
|
597
1060
|
short: `Class of this ${fieldName.single} is manually instantiated. ` +
|
|
598
|
-
'This is discouraged and prevents migration',
|
|
1061
|
+
'This is discouraged and prevents migration.',
|
|
599
1062
|
extra: `Signal ${fieldName.plural} require a DI injection context. Manually instantiating ` +
|
|
600
1063
|
'breaks this requirement in some cases, so the migration is skipped.',
|
|
601
1064
|
};
|
|
@@ -1113,22 +1576,23 @@ function analyzeControlFlow(entries, checker) {
|
|
|
1113
1576
|
const referenceToMetadata = new Map();
|
|
1114
1577
|
// Prepare easy lookups for reference nodes to flow info.
|
|
1115
1578
|
for (const [idx, entry] of entries.entries()) {
|
|
1579
|
+
const flowContainer = getControlFlowContainer(entry);
|
|
1116
1580
|
referenceToMetadata.set(entry, {
|
|
1117
|
-
flowContainer
|
|
1581
|
+
flowContainer,
|
|
1118
1582
|
resultIndex: idx,
|
|
1119
1583
|
});
|
|
1584
|
+
result.push({
|
|
1585
|
+
flowContainer,
|
|
1586
|
+
id: idx,
|
|
1587
|
+
originalNode: entry,
|
|
1588
|
+
recommendedNode: 'preserve',
|
|
1589
|
+
});
|
|
1120
1590
|
}
|
|
1121
1591
|
for (const entry of entries) {
|
|
1122
1592
|
const { flowContainer, resultIndex } = referenceToMetadata.get(entry);
|
|
1123
1593
|
const flowPathInterestingNodes = traverseFlowForInterestingNodes(getFlowNode(entry));
|
|
1124
1594
|
assert__default["default"](flowContainer !== null && flowPathInterestingNodes !== null, 'Expected a flow container to exist.');
|
|
1125
1595
|
const narrowPartners = getAllMatchingReferencesInFlowPath(flowPathInterestingNodes, entry, referenceToMetadata, flowContainer, checker);
|
|
1126
|
-
result.push({
|
|
1127
|
-
id: resultIndex,
|
|
1128
|
-
originalNode: entry,
|
|
1129
|
-
flowContainer,
|
|
1130
|
-
recommendedNode: 'preserve',
|
|
1131
|
-
});
|
|
1132
1596
|
if (narrowPartners.length !== 0) {
|
|
1133
1597
|
connectSharedReferences(result, narrowPartners, resultIndex);
|
|
1134
1598
|
}
|
|
@@ -1155,21 +1619,26 @@ function connectSharedReferences(result, flowPartners, refId) {
|
|
|
1155
1619
|
}
|
|
1156
1620
|
assert__default["default"](earliestPartner !== null, 'Expected an earliest partner to be found.');
|
|
1157
1621
|
assert__default["default"](earliestPartnerId !== null, 'Expected an earliest partner to be found.');
|
|
1622
|
+
// Earliest partner ID could be higher than `refId` in cyclic
|
|
1623
|
+
// situations like `loop` flow nodes. We need to find the minimum
|
|
1624
|
+
// and maximum to iterate through partners in between.
|
|
1625
|
+
const min = Math.min(earliestPartnerId, refId);
|
|
1626
|
+
const max = Math.max(earliestPartnerId, refId);
|
|
1158
1627
|
// Then, incorporate all similar references (or flow nodes) in between
|
|
1159
1628
|
// the reference and the earliest partner. References in between can also
|
|
1160
1629
|
// use the shared flow node and not preserve their original reference— as
|
|
1161
1630
|
// this would be rather unreadable and inefficient.
|
|
1162
1631
|
const seenBlocks = new Set();
|
|
1163
1632
|
let highestBlock = null;
|
|
1164
|
-
for (let i =
|
|
1633
|
+
for (let i = min; i <= max; i++) {
|
|
1165
1634
|
// Different flow container captured sequentially in result. Ignore.
|
|
1166
1635
|
if (result[i].flowContainer !== refFlowContainer) {
|
|
1167
1636
|
continue;
|
|
1168
1637
|
}
|
|
1169
1638
|
// Iterate up the block, find the highest block within the flow container.
|
|
1170
1639
|
let current = result[i].originalNode.parent;
|
|
1171
|
-
while (current !== undefined
|
|
1172
|
-
if (
|
|
1640
|
+
while (current !== undefined) {
|
|
1641
|
+
if (isPotentialInsertionAncestor(current)) {
|
|
1173
1642
|
// If we saw this block already, it is a common ancestor from another
|
|
1174
1643
|
// partner. Check if it would be higher than the current highest block;
|
|
1175
1644
|
// and choose it accordingly.
|
|
@@ -1187,14 +1656,17 @@ function connectSharedReferences(result, flowPartners, refId) {
|
|
|
1187
1656
|
result[i].recommendedNode = earliestPartnerId;
|
|
1188
1657
|
}
|
|
1189
1658
|
}
|
|
1659
|
+
if (!highestBlock) {
|
|
1660
|
+
console.error(earliestPartnerId, refId, refFlowContainer.getText(), seenBlocks);
|
|
1661
|
+
}
|
|
1190
1662
|
assert__default["default"](highestBlock, 'Expected a block anchor to be found');
|
|
1191
1663
|
result[earliestPartnerId].recommendedNode = highestBlock;
|
|
1192
1664
|
}
|
|
1193
|
-
function
|
|
1665
|
+
function isPotentialInsertionAncestor(node) {
|
|
1194
1666
|
// Note: Arrow functions may not have a block, but instead use an expression
|
|
1195
1667
|
// directly. This still signifies a "block" as we can convert the concise body
|
|
1196
1668
|
// to a block.
|
|
1197
|
-
return ts__default["default"].isSourceFile(node) || ts__default["default"].isBlock(node) || ts__default["default"].isArrowFunction(node);
|
|
1669
|
+
return (ts__default["default"].isSourceFile(node) || ts__default["default"].isBlock(node) || ts__default["default"].isArrowFunction(node) || ts__default["default"].isClassLike(node));
|
|
1198
1670
|
}
|
|
1199
1671
|
/**
|
|
1200
1672
|
* Looks through the flow path and interesting nodes to determine which
|
|
@@ -1271,6 +1743,17 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1271
1743
|
for (const reference of tsReferencesWithNarrowing.values()) {
|
|
1272
1744
|
const controlFlowResult = analyzeControlFlow(reference.accesses, checker);
|
|
1273
1745
|
const idToSharedField = new Map();
|
|
1746
|
+
const isSharePartnerRef = (val) => {
|
|
1747
|
+
return val !== 'preserve' && typeof val !== 'number';
|
|
1748
|
+
};
|
|
1749
|
+
// Ensure we generate shared fields before reference entries.
|
|
1750
|
+
// This allows us to safely make use of `idToSharedField` whenever we come
|
|
1751
|
+
// across a referenced pointing to a share partner.
|
|
1752
|
+
controlFlowResult.sort((a, b) => {
|
|
1753
|
+
const aPriority = isSharePartnerRef(a.recommendedNode) ? 1 : 0;
|
|
1754
|
+
const bPriority = isSharePartnerRef(b.recommendedNode) ? 1 : 0;
|
|
1755
|
+
return bPriority - aPriority;
|
|
1756
|
+
});
|
|
1274
1757
|
for (const { id, originalNode, recommendedNode } of controlFlowResult) {
|
|
1275
1758
|
const sf = originalNode.getSourceFile();
|
|
1276
1759
|
// Original node is preserved. No narrowing, and hence not shared.
|
|
@@ -1287,12 +1770,14 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1287
1770
|
// This reference is shared with a previous reference. Replace the access
|
|
1288
1771
|
// with the temporary variable.
|
|
1289
1772
|
if (typeof recommendedNode === 'number') {
|
|
1773
|
+
// Extract the shared field name.
|
|
1774
|
+
const toInsert = idToSharedField.get(recommendedNode);
|
|
1290
1775
|
const replaceNode = combine_units.traverseAccess(originalNode);
|
|
1776
|
+
assert__default["default"](toInsert, 'no shared variable yet available');
|
|
1291
1777
|
replacements.push(new combine_units.Replacement(combine_units.projectFile(sf, info), new combine_units.TextUpdate({
|
|
1292
1778
|
position: replaceNode.getStart(),
|
|
1293
1779
|
end: replaceNode.getEnd(),
|
|
1294
|
-
|
|
1295
|
-
toInsert: idToSharedField.get(recommendedNode),
|
|
1780
|
+
toInsert,
|
|
1296
1781
|
})));
|
|
1297
1782
|
continue;
|
|
1298
1783
|
}
|
|
@@ -1309,10 +1794,20 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1309
1794
|
parent = parent.parent;
|
|
1310
1795
|
}
|
|
1311
1796
|
const replaceNode = combine_units.traverseAccess(originalNode);
|
|
1312
|
-
const fieldName = nameGenerator.generate(originalNode.text, referenceNodeInBlock);
|
|
1313
1797
|
const filePath = combine_units.projectFile(sf, info);
|
|
1314
|
-
const
|
|
1315
|
-
|
|
1798
|
+
const initializer = `${replaceNode.getText()}()`;
|
|
1799
|
+
const fieldName = nameGenerator.generate(originalNode.text, referenceNodeInBlock);
|
|
1800
|
+
let sharedValueAccessExpr;
|
|
1801
|
+
let temporaryVariableStr;
|
|
1802
|
+
if (ts__default["default"].isClassLike(recommendedNode)) {
|
|
1803
|
+
sharedValueAccessExpr = `this.${fieldName}`;
|
|
1804
|
+
temporaryVariableStr = `private readonly ${fieldName} = ${initializer};`;
|
|
1805
|
+
}
|
|
1806
|
+
else {
|
|
1807
|
+
sharedValueAccessExpr = fieldName;
|
|
1808
|
+
temporaryVariableStr = `const ${fieldName} = ${initializer};`;
|
|
1809
|
+
}
|
|
1810
|
+
idToSharedField.set(id, sharedValueAccessExpr);
|
|
1316
1811
|
// If the common ancestor block of all shared references is an arrow function
|
|
1317
1812
|
// without a block, convert the arrow function to a block and insert the temporary
|
|
1318
1813
|
// variable at the beginning.
|
|
@@ -1330,7 +1825,7 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1330
1825
|
replacements.push(new combine_units.Replacement(combine_units.projectFile(sf, info), new combine_units.TextUpdate({
|
|
1331
1826
|
position: replaceNode.getStart(),
|
|
1332
1827
|
end: replaceNode.getEnd(),
|
|
1333
|
-
toInsert:
|
|
1828
|
+
toInsert: sharedValueAccessExpr,
|
|
1334
1829
|
})));
|
|
1335
1830
|
}
|
|
1336
1831
|
}
|
|
@@ -1448,6 +1943,7 @@ function migrateTypeScriptTypeReferences(host, references, importManager, info)
|
|
|
1448
1943
|
|
|
1449
1944
|
exports.GroupedTsAstVisitor = GroupedTsAstVisitor;
|
|
1450
1945
|
exports.InheritanceGraph = InheritanceGraph;
|
|
1946
|
+
exports.NULL_EXPR = NULL_EXPR;
|
|
1451
1947
|
exports.checkIncompatiblePatterns = checkIncompatiblePatterns;
|
|
1452
1948
|
exports.checkInheritanceOfKnownFields = checkInheritanceOfKnownFields;
|
|
1453
1949
|
exports.cutStringToLineLimit = cutStringToLineLimit;
|