@angular/core 21.0.0-next.0 → 21.0.0-next.10
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/_attribute-chunk.mjs +12 -0
- package/fesm2022/_attribute-chunk.mjs.map +1 -0
- package/fesm2022/_debug_node-chunk.mjs +18469 -0
- package/fesm2022/_debug_node-chunk.mjs.map +1 -0
- package/fesm2022/_effect-chunk.mjs +423 -0
- package/fesm2022/_effect-chunk.mjs.map +1 -0
- package/fesm2022/_effect-chunk2.mjs +2951 -0
- package/fesm2022/_effect-chunk2.mjs.map +1 -0
- package/fesm2022/_not_found-chunk.mjs +39 -0
- package/fesm2022/_not_found-chunk.mjs.map +1 -0
- package/fesm2022/_resource-chunk.mjs +378 -0
- package/fesm2022/_resource-chunk.mjs.map +1 -0
- package/fesm2022/_untracked-chunk.mjs +96 -0
- package/fesm2022/_untracked-chunk.mjs.map +1 -0
- package/fesm2022/_weak_ref-chunk.mjs +10 -0
- package/fesm2022/_weak_ref-chunk.mjs.map +1 -0
- package/fesm2022/core.mjs +2499 -4185
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives-di.mjs +23 -0
- package/fesm2022/primitives-di.mjs.map +1 -0
- package/fesm2022/primitives-event-dispatch.mjs +788 -0
- package/fesm2022/primitives-event-dispatch.mjs.map +1 -0
- package/fesm2022/primitives-signals.mjs +187 -0
- package/fesm2022/primitives-signals.mjs.map +1 -0
- package/fesm2022/rxjs-interop.mjs +210 -308
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +2309 -3170
- package/fesm2022/testing.mjs.map +1 -1
- package/package.json +18 -12
- package/resources/best-practices.md +56 -0
- package/schematics/bundles/add-bootstrap-context-to-server-main.cjs +117 -0
- package/schematics/bundles/application-config-core.cjs +84 -0
- package/schematics/bundles/{apply_import_manager-DR9xXCle.cjs → apply_import_manager-1Zs_gpB6.cjs} +4 -5
- package/schematics/bundles/bootstrap-options-migration.cjs +598 -0
- package/schematics/bundles/cleanup-unused-imports.cjs +9 -13
- package/schematics/bundles/common-to-standalone-migration.cjs +381 -0
- package/schematics/bundles/{compiler_host-BXBP7CE2.cjs → compiler_host-DBwYMlTo.cjs} +10 -11
- package/schematics/bundles/control-flow-migration.cjs +122 -119
- package/schematics/bundles/{imports-CIX-JgAN.cjs → imports-DP72APSx.cjs} +6 -1
- package/schematics/bundles/{index-CfTQUOiz.cjs → index-B7I9sIUx.cjs} +36 -39
- package/schematics/bundles/inject-migration.cjs +148 -70
- package/schematics/bundles/leading_space-D9nQ8UQC.cjs +1 -1
- package/schematics/bundles/{migrate_ts_type_references-6NtAj-Wk.cjs → migrate_ts_type_references-UGIUl7En.cjs} +500 -24
- package/schematics/bundles/ng_component_template-Dsuq1Lw7.cjs +185 -0
- package/schematics/bundles/{ng_decorators-B5HCqr20.cjs → ng_decorators-DSFlWYQY.cjs} +2 -2
- package/schematics/bundles/ngclass-to-class-migration.cjs +542 -0
- package/schematics/bundles/ngstyle-to-style-migration.cjs +487 -0
- package/schematics/bundles/nodes-B16H9JUd.cjs +1 -1
- package/schematics/bundles/output-migration.cjs +16 -19
- package/schematics/bundles/parse_html-8VLCL37B.cjs +132 -0
- package/schematics/bundles/{project_paths-DcaODbky.cjs → project_paths-DvD50ouC.cjs} +14 -247
- package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.cjs +90 -0
- package/schematics/bundles/property_name-BBwFuqMe.cjs +1 -1
- package/schematics/bundles/route-lazy-loading.cjs +54 -26
- package/schematics/bundles/router-current-navigation.cjs +7 -18
- package/schematics/bundles/router-last-successful-navigation.cjs +7 -18
- package/schematics/bundles/router-testing-module-migration.cjs +502 -0
- package/schematics/bundles/self-closing-tags-migration.cjs +17 -216
- package/schematics/bundles/signal-input-migration.cjs +93 -29
- package/schematics/bundles/signal-queries-migration.cjs +22 -25
- package/schematics/bundles/signals.cjs +10 -13
- package/schematics/bundles/standalone-migration.cjs +135 -102
- package/schematics/bundles/{symbol-VPWguRxr.cjs → symbol-BObKoqes.cjs} +3 -2
- package/schematics/collection.json +23 -0
- package/schematics/migrations/common-to-standalone-migration/schema.json +14 -0
- package/schematics/migrations/ngclass-to-class-migration/schema.json +20 -0
- package/schematics/migrations/ngstyle-to-style-migration/schema.json +20 -0
- package/schematics/migrations/router-testing-module-migration/schema.json +14 -0
- package/schematics/migrations.json +16 -2
- package/{api.d.d.ts → types/_api-chunk.d.ts} +9 -6
- package/{chrome_dev_tools_performance.d.d.ts → types/_chrome_dev_tools_performance-chunk.d.ts} +26 -31
- package/{discovery.d.d.ts → types/_discovery-chunk.d.ts} +135 -98
- package/{signal.d.d.ts → types/_effect-chunk.d.ts} +14 -5
- package/{event_dispatcher.d.d.ts → types/_event_dispatcher-chunk.d.ts} +2 -2
- package/{graph.d.d.ts → types/_formatter-chunk.d.ts} +40 -7
- package/{weak_ref.d.d.ts → types/_weak_ref-chunk.d.ts} +2 -2
- package/{index.d.ts → types/core.d.ts} +233 -305
- package/{primitives/di/index.d.ts → types/primitives-di.d.ts} +2 -2
- package/{primitives/event-dispatch/index.d.ts → types/primitives-event-dispatch.d.ts} +4 -4
- package/{primitives/signals/index.d.ts → types/primitives-signals.d.ts} +7 -8
- package/{rxjs-interop/index.d.ts → types/rxjs-interop.d.ts} +8 -6
- package/{testing/index.d.ts → types/testing.d.ts} +7 -7
- package/fesm2022/attribute.mjs +0 -24
- package/fesm2022/attribute.mjs.map +0 -1
- package/fesm2022/debug_node.mjs +0 -31833
- package/fesm2022/debug_node.mjs.map +0 -1
- package/fesm2022/not_found.mjs +0 -56
- package/fesm2022/not_found.mjs.map +0 -1
- package/fesm2022/primitives/di.mjs +0 -23
- package/fesm2022/primitives/di.mjs.map +0 -1
- package/fesm2022/primitives/event-dispatch.mjs +0 -1622
- package/fesm2022/primitives/event-dispatch.mjs.map +0 -1
- package/fesm2022/primitives/signals.mjs +0 -89
- package/fesm2022/primitives/signals.mjs.map +0 -1
- package/fesm2022/resource.mjs +0 -633
- package/fesm2022/resource.mjs.map +0 -1
- package/fesm2022/root_effect_scheduler.mjs +0 -4007
- package/fesm2022/root_effect_scheduler.mjs.map +0 -1
- package/fesm2022/signal.mjs +0 -560
- package/fesm2022/signal.mjs.map +0 -1
- package/fesm2022/untracked.mjs +0 -117
- package/fesm2022/untracked.mjs.map +0 -1
- package/fesm2022/weak_ref.mjs +0 -12
- package/fesm2022/weak_ref.mjs.map +0 -1
- package/schematics/bundles/index-esqfDjNB.cjs +0 -22074
- package/schematics/bundles/project_tsconfig_paths-CS-eSeHC.cjs +0 -51062
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v21.0.0-next.
|
|
3
|
+
* @license Angular v21.0.0-next.10
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
var project_tsconfig_paths = require('./project_tsconfig_paths-CS-eSeHC.cjs');
|
|
10
|
-
var ts = require('typescript');
|
|
11
|
-
require('os');
|
|
12
9
|
var assert = require('assert');
|
|
13
|
-
var
|
|
14
|
-
var
|
|
10
|
+
var ts = require('typescript');
|
|
11
|
+
var migrations = require('@angular/compiler-cli/private/migrations');
|
|
12
|
+
var index = require('./index-B7I9sIUx.cjs');
|
|
13
|
+
var project_paths = require('./project_paths-DvD50ouC.cjs');
|
|
15
14
|
var leading_space = require('./leading_space-D9nQ8UQC.cjs');
|
|
16
|
-
require('
|
|
17
|
-
require('path');
|
|
15
|
+
require('@angular/compiler-cli');
|
|
18
16
|
require('node:path');
|
|
19
17
|
|
|
20
18
|
/**
|
|
@@ -77,6 +75,441 @@ function pickFieldIncompatibility(a, b) {
|
|
|
77
75
|
return a;
|
|
78
76
|
}
|
|
79
77
|
|
|
78
|
+
/**
|
|
79
|
+
* A lazily created TextEncoder instance for converting strings into UTF-8 bytes
|
|
80
|
+
*/
|
|
81
|
+
// Utils
|
|
82
|
+
var Endian;
|
|
83
|
+
(function (Endian) {
|
|
84
|
+
Endian[Endian["Little"] = 0] = "Little";
|
|
85
|
+
Endian[Endian["Big"] = 1] = "Big";
|
|
86
|
+
})(Endian || (Endian = {}));
|
|
87
|
+
|
|
88
|
+
//// Types
|
|
89
|
+
var TypeModifier;
|
|
90
|
+
(function (TypeModifier) {
|
|
91
|
+
TypeModifier[TypeModifier["None"] = 0] = "None";
|
|
92
|
+
TypeModifier[TypeModifier["Const"] = 1] = "Const";
|
|
93
|
+
})(TypeModifier || (TypeModifier = {}));
|
|
94
|
+
class Type {
|
|
95
|
+
modifiers;
|
|
96
|
+
constructor(modifiers = TypeModifier.None) {
|
|
97
|
+
this.modifiers = modifiers;
|
|
98
|
+
}
|
|
99
|
+
hasModifier(modifier) {
|
|
100
|
+
return (this.modifiers & modifier) !== 0;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
var BuiltinTypeName;
|
|
104
|
+
(function (BuiltinTypeName) {
|
|
105
|
+
BuiltinTypeName[BuiltinTypeName["Dynamic"] = 0] = "Dynamic";
|
|
106
|
+
BuiltinTypeName[BuiltinTypeName["Bool"] = 1] = "Bool";
|
|
107
|
+
BuiltinTypeName[BuiltinTypeName["String"] = 2] = "String";
|
|
108
|
+
BuiltinTypeName[BuiltinTypeName["Int"] = 3] = "Int";
|
|
109
|
+
BuiltinTypeName[BuiltinTypeName["Number"] = 4] = "Number";
|
|
110
|
+
BuiltinTypeName[BuiltinTypeName["Function"] = 5] = "Function";
|
|
111
|
+
BuiltinTypeName[BuiltinTypeName["Inferred"] = 6] = "Inferred";
|
|
112
|
+
BuiltinTypeName[BuiltinTypeName["None"] = 7] = "None";
|
|
113
|
+
})(BuiltinTypeName || (BuiltinTypeName = {}));
|
|
114
|
+
class BuiltinType extends Type {
|
|
115
|
+
name;
|
|
116
|
+
constructor(name, modifiers) {
|
|
117
|
+
super(modifiers);
|
|
118
|
+
this.name = name;
|
|
119
|
+
}
|
|
120
|
+
visitType(visitor, context) {
|
|
121
|
+
return visitor.visitBuiltinType(this, context);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
new BuiltinType(BuiltinTypeName.Dynamic);
|
|
125
|
+
const INFERRED_TYPE = new BuiltinType(BuiltinTypeName.Inferred);
|
|
126
|
+
new BuiltinType(BuiltinTypeName.Bool);
|
|
127
|
+
new BuiltinType(BuiltinTypeName.Int);
|
|
128
|
+
new BuiltinType(BuiltinTypeName.Number);
|
|
129
|
+
new BuiltinType(BuiltinTypeName.String);
|
|
130
|
+
new BuiltinType(BuiltinTypeName.Function);
|
|
131
|
+
new BuiltinType(BuiltinTypeName.None);
|
|
132
|
+
///// Expressions
|
|
133
|
+
var UnaryOperator;
|
|
134
|
+
(function (UnaryOperator) {
|
|
135
|
+
UnaryOperator[UnaryOperator["Minus"] = 0] = "Minus";
|
|
136
|
+
UnaryOperator[UnaryOperator["Plus"] = 1] = "Plus";
|
|
137
|
+
})(UnaryOperator || (UnaryOperator = {}));
|
|
138
|
+
var BinaryOperator;
|
|
139
|
+
(function (BinaryOperator) {
|
|
140
|
+
BinaryOperator[BinaryOperator["Equals"] = 0] = "Equals";
|
|
141
|
+
BinaryOperator[BinaryOperator["NotEquals"] = 1] = "NotEquals";
|
|
142
|
+
BinaryOperator[BinaryOperator["Assign"] = 2] = "Assign";
|
|
143
|
+
BinaryOperator[BinaryOperator["Identical"] = 3] = "Identical";
|
|
144
|
+
BinaryOperator[BinaryOperator["NotIdentical"] = 4] = "NotIdentical";
|
|
145
|
+
BinaryOperator[BinaryOperator["Minus"] = 5] = "Minus";
|
|
146
|
+
BinaryOperator[BinaryOperator["Plus"] = 6] = "Plus";
|
|
147
|
+
BinaryOperator[BinaryOperator["Divide"] = 7] = "Divide";
|
|
148
|
+
BinaryOperator[BinaryOperator["Multiply"] = 8] = "Multiply";
|
|
149
|
+
BinaryOperator[BinaryOperator["Modulo"] = 9] = "Modulo";
|
|
150
|
+
BinaryOperator[BinaryOperator["And"] = 10] = "And";
|
|
151
|
+
BinaryOperator[BinaryOperator["Or"] = 11] = "Or";
|
|
152
|
+
BinaryOperator[BinaryOperator["BitwiseOr"] = 12] = "BitwiseOr";
|
|
153
|
+
BinaryOperator[BinaryOperator["BitwiseAnd"] = 13] = "BitwiseAnd";
|
|
154
|
+
BinaryOperator[BinaryOperator["Lower"] = 14] = "Lower";
|
|
155
|
+
BinaryOperator[BinaryOperator["LowerEquals"] = 15] = "LowerEquals";
|
|
156
|
+
BinaryOperator[BinaryOperator["Bigger"] = 16] = "Bigger";
|
|
157
|
+
BinaryOperator[BinaryOperator["BiggerEquals"] = 17] = "BiggerEquals";
|
|
158
|
+
BinaryOperator[BinaryOperator["NullishCoalesce"] = 18] = "NullishCoalesce";
|
|
159
|
+
BinaryOperator[BinaryOperator["Exponentiation"] = 19] = "Exponentiation";
|
|
160
|
+
BinaryOperator[BinaryOperator["In"] = 20] = "In";
|
|
161
|
+
BinaryOperator[BinaryOperator["AdditionAssignment"] = 21] = "AdditionAssignment";
|
|
162
|
+
BinaryOperator[BinaryOperator["SubtractionAssignment"] = 22] = "SubtractionAssignment";
|
|
163
|
+
BinaryOperator[BinaryOperator["MultiplicationAssignment"] = 23] = "MultiplicationAssignment";
|
|
164
|
+
BinaryOperator[BinaryOperator["DivisionAssignment"] = 24] = "DivisionAssignment";
|
|
165
|
+
BinaryOperator[BinaryOperator["RemainderAssignment"] = 25] = "RemainderAssignment";
|
|
166
|
+
BinaryOperator[BinaryOperator["ExponentiationAssignment"] = 26] = "ExponentiationAssignment";
|
|
167
|
+
BinaryOperator[BinaryOperator["AndAssignment"] = 27] = "AndAssignment";
|
|
168
|
+
BinaryOperator[BinaryOperator["OrAssignment"] = 28] = "OrAssignment";
|
|
169
|
+
BinaryOperator[BinaryOperator["NullishCoalesceAssignment"] = 29] = "NullishCoalesceAssignment";
|
|
170
|
+
})(BinaryOperator || (BinaryOperator = {}));
|
|
171
|
+
function nullSafeIsEquivalent(base, other) {
|
|
172
|
+
if (base == null || other == null) {
|
|
173
|
+
return base == other;
|
|
174
|
+
}
|
|
175
|
+
return base.isEquivalent(other);
|
|
176
|
+
}
|
|
177
|
+
function areAllEquivalentPredicate(base, other, equivalentPredicate) {
|
|
178
|
+
const len = base.length;
|
|
179
|
+
if (len !== other.length) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
for (let i = 0; i < len; i++) {
|
|
183
|
+
if (!equivalentPredicate(base[i], other[i])) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
function areAllEquivalent(base, other) {
|
|
190
|
+
return areAllEquivalentPredicate(base, other, (baseElement, otherElement) => baseElement.isEquivalent(otherElement));
|
|
191
|
+
}
|
|
192
|
+
class Expression {
|
|
193
|
+
type;
|
|
194
|
+
sourceSpan;
|
|
195
|
+
constructor(type, sourceSpan) {
|
|
196
|
+
this.type = type || null;
|
|
197
|
+
this.sourceSpan = sourceSpan || null;
|
|
198
|
+
}
|
|
199
|
+
prop(name, sourceSpan) {
|
|
200
|
+
return new ReadPropExpr(this, name, null, sourceSpan);
|
|
201
|
+
}
|
|
202
|
+
key(index, type, sourceSpan) {
|
|
203
|
+
return new ReadKeyExpr(this, index, type, sourceSpan);
|
|
204
|
+
}
|
|
205
|
+
callFn(params, sourceSpan, pure) {
|
|
206
|
+
return new InvokeFunctionExpr(this, params, null, sourceSpan, pure);
|
|
207
|
+
}
|
|
208
|
+
instantiate(params, type, sourceSpan) {
|
|
209
|
+
return new InstantiateExpr(this, params, type, sourceSpan);
|
|
210
|
+
}
|
|
211
|
+
conditional(trueCase, falseCase = null, sourceSpan) {
|
|
212
|
+
return new ConditionalExpr(this, trueCase, falseCase, null, sourceSpan);
|
|
213
|
+
}
|
|
214
|
+
equals(rhs, sourceSpan) {
|
|
215
|
+
return new BinaryOperatorExpr(BinaryOperator.Equals, this, rhs, null, sourceSpan);
|
|
216
|
+
}
|
|
217
|
+
notEquals(rhs, sourceSpan) {
|
|
218
|
+
return new BinaryOperatorExpr(BinaryOperator.NotEquals, this, rhs, null, sourceSpan);
|
|
219
|
+
}
|
|
220
|
+
identical(rhs, sourceSpan) {
|
|
221
|
+
return new BinaryOperatorExpr(BinaryOperator.Identical, this, rhs, null, sourceSpan);
|
|
222
|
+
}
|
|
223
|
+
notIdentical(rhs, sourceSpan) {
|
|
224
|
+
return new BinaryOperatorExpr(BinaryOperator.NotIdentical, this, rhs, null, sourceSpan);
|
|
225
|
+
}
|
|
226
|
+
minus(rhs, sourceSpan) {
|
|
227
|
+
return new BinaryOperatorExpr(BinaryOperator.Minus, this, rhs, null, sourceSpan);
|
|
228
|
+
}
|
|
229
|
+
plus(rhs, sourceSpan) {
|
|
230
|
+
return new BinaryOperatorExpr(BinaryOperator.Plus, this, rhs, null, sourceSpan);
|
|
231
|
+
}
|
|
232
|
+
divide(rhs, sourceSpan) {
|
|
233
|
+
return new BinaryOperatorExpr(BinaryOperator.Divide, this, rhs, null, sourceSpan);
|
|
234
|
+
}
|
|
235
|
+
multiply(rhs, sourceSpan) {
|
|
236
|
+
return new BinaryOperatorExpr(BinaryOperator.Multiply, this, rhs, null, sourceSpan);
|
|
237
|
+
}
|
|
238
|
+
modulo(rhs, sourceSpan) {
|
|
239
|
+
return new BinaryOperatorExpr(BinaryOperator.Modulo, this, rhs, null, sourceSpan);
|
|
240
|
+
}
|
|
241
|
+
power(rhs, sourceSpan) {
|
|
242
|
+
return new BinaryOperatorExpr(BinaryOperator.Exponentiation, this, rhs, null, sourceSpan);
|
|
243
|
+
}
|
|
244
|
+
and(rhs, sourceSpan) {
|
|
245
|
+
return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan);
|
|
246
|
+
}
|
|
247
|
+
bitwiseOr(rhs, sourceSpan) {
|
|
248
|
+
return new BinaryOperatorExpr(BinaryOperator.BitwiseOr, this, rhs, null, sourceSpan);
|
|
249
|
+
}
|
|
250
|
+
bitwiseAnd(rhs, sourceSpan) {
|
|
251
|
+
return new BinaryOperatorExpr(BinaryOperator.BitwiseAnd, this, rhs, null, sourceSpan);
|
|
252
|
+
}
|
|
253
|
+
or(rhs, sourceSpan) {
|
|
254
|
+
return new BinaryOperatorExpr(BinaryOperator.Or, this, rhs, null, sourceSpan);
|
|
255
|
+
}
|
|
256
|
+
lower(rhs, sourceSpan) {
|
|
257
|
+
return new BinaryOperatorExpr(BinaryOperator.Lower, this, rhs, null, sourceSpan);
|
|
258
|
+
}
|
|
259
|
+
lowerEquals(rhs, sourceSpan) {
|
|
260
|
+
return new BinaryOperatorExpr(BinaryOperator.LowerEquals, this, rhs, null, sourceSpan);
|
|
261
|
+
}
|
|
262
|
+
bigger(rhs, sourceSpan) {
|
|
263
|
+
return new BinaryOperatorExpr(BinaryOperator.Bigger, this, rhs, null, sourceSpan);
|
|
264
|
+
}
|
|
265
|
+
biggerEquals(rhs, sourceSpan) {
|
|
266
|
+
return new BinaryOperatorExpr(BinaryOperator.BiggerEquals, this, rhs, null, sourceSpan);
|
|
267
|
+
}
|
|
268
|
+
isBlank(sourceSpan) {
|
|
269
|
+
// Note: We use equals by purpose here to compare to null and undefined in JS.
|
|
270
|
+
// We use the typed null to allow strictNullChecks to narrow types.
|
|
271
|
+
return this.equals(TYPED_NULL_EXPR, sourceSpan);
|
|
272
|
+
}
|
|
273
|
+
nullishCoalesce(rhs, sourceSpan) {
|
|
274
|
+
return new BinaryOperatorExpr(BinaryOperator.NullishCoalesce, this, rhs, null, sourceSpan);
|
|
275
|
+
}
|
|
276
|
+
toStmt() {
|
|
277
|
+
return new ExpressionStatement(this, null);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
class InvokeFunctionExpr extends Expression {
|
|
281
|
+
fn;
|
|
282
|
+
args;
|
|
283
|
+
pure;
|
|
284
|
+
constructor(fn, args, type, sourceSpan, pure = false) {
|
|
285
|
+
super(type, sourceSpan);
|
|
286
|
+
this.fn = fn;
|
|
287
|
+
this.args = args;
|
|
288
|
+
this.pure = pure;
|
|
289
|
+
}
|
|
290
|
+
// An alias for fn, which allows other logic to handle calls and property reads together.
|
|
291
|
+
get receiver() {
|
|
292
|
+
return this.fn;
|
|
293
|
+
}
|
|
294
|
+
isEquivalent(e) {
|
|
295
|
+
return (e instanceof InvokeFunctionExpr &&
|
|
296
|
+
this.fn.isEquivalent(e.fn) &&
|
|
297
|
+
areAllEquivalent(this.args, e.args) &&
|
|
298
|
+
this.pure === e.pure);
|
|
299
|
+
}
|
|
300
|
+
isConstant() {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
visitExpression(visitor, context) {
|
|
304
|
+
return visitor.visitInvokeFunctionExpr(this, context);
|
|
305
|
+
}
|
|
306
|
+
clone() {
|
|
307
|
+
return new InvokeFunctionExpr(this.fn.clone(), this.args.map((arg) => arg.clone()), this.type, this.sourceSpan, this.pure);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
class InstantiateExpr extends Expression {
|
|
311
|
+
classExpr;
|
|
312
|
+
args;
|
|
313
|
+
constructor(classExpr, args, type, sourceSpan) {
|
|
314
|
+
super(type, sourceSpan);
|
|
315
|
+
this.classExpr = classExpr;
|
|
316
|
+
this.args = args;
|
|
317
|
+
}
|
|
318
|
+
isEquivalent(e) {
|
|
319
|
+
return (e instanceof InstantiateExpr &&
|
|
320
|
+
this.classExpr.isEquivalent(e.classExpr) &&
|
|
321
|
+
areAllEquivalent(this.args, e.args));
|
|
322
|
+
}
|
|
323
|
+
isConstant() {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
visitExpression(visitor, context) {
|
|
327
|
+
return visitor.visitInstantiateExpr(this, context);
|
|
328
|
+
}
|
|
329
|
+
clone() {
|
|
330
|
+
return new InstantiateExpr(this.classExpr.clone(), this.args.map((arg) => arg.clone()), this.type, this.sourceSpan);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
class LiteralExpr extends Expression {
|
|
334
|
+
value;
|
|
335
|
+
constructor(value, type, sourceSpan) {
|
|
336
|
+
super(type, sourceSpan);
|
|
337
|
+
this.value = value;
|
|
338
|
+
}
|
|
339
|
+
isEquivalent(e) {
|
|
340
|
+
return e instanceof LiteralExpr && this.value === e.value;
|
|
341
|
+
}
|
|
342
|
+
isConstant() {
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
visitExpression(visitor, context) {
|
|
346
|
+
return visitor.visitLiteralExpr(this, context);
|
|
347
|
+
}
|
|
348
|
+
clone() {
|
|
349
|
+
return new LiteralExpr(this.value, this.type, this.sourceSpan);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
class ConditionalExpr extends Expression {
|
|
353
|
+
condition;
|
|
354
|
+
falseCase;
|
|
355
|
+
trueCase;
|
|
356
|
+
constructor(condition, trueCase, falseCase = null, type, sourceSpan) {
|
|
357
|
+
super(type || trueCase.type, sourceSpan);
|
|
358
|
+
this.condition = condition;
|
|
359
|
+
this.falseCase = falseCase;
|
|
360
|
+
this.trueCase = trueCase;
|
|
361
|
+
}
|
|
362
|
+
isEquivalent(e) {
|
|
363
|
+
return (e instanceof ConditionalExpr &&
|
|
364
|
+
this.condition.isEquivalent(e.condition) &&
|
|
365
|
+
this.trueCase.isEquivalent(e.trueCase) &&
|
|
366
|
+
nullSafeIsEquivalent(this.falseCase, e.falseCase));
|
|
367
|
+
}
|
|
368
|
+
isConstant() {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
visitExpression(visitor, context) {
|
|
372
|
+
return visitor.visitConditionalExpr(this, context);
|
|
373
|
+
}
|
|
374
|
+
clone() {
|
|
375
|
+
return new ConditionalExpr(this.condition.clone(), this.trueCase.clone(), this.falseCase?.clone(), this.type, this.sourceSpan);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
class BinaryOperatorExpr extends Expression {
|
|
379
|
+
operator;
|
|
380
|
+
rhs;
|
|
381
|
+
lhs;
|
|
382
|
+
constructor(operator, lhs, rhs, type, sourceSpan) {
|
|
383
|
+
super(type || lhs.type, sourceSpan);
|
|
384
|
+
this.operator = operator;
|
|
385
|
+
this.rhs = rhs;
|
|
386
|
+
this.lhs = lhs;
|
|
387
|
+
}
|
|
388
|
+
isEquivalent(e) {
|
|
389
|
+
return (e instanceof BinaryOperatorExpr &&
|
|
390
|
+
this.operator === e.operator &&
|
|
391
|
+
this.lhs.isEquivalent(e.lhs) &&
|
|
392
|
+
this.rhs.isEquivalent(e.rhs));
|
|
393
|
+
}
|
|
394
|
+
isConstant() {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
visitExpression(visitor, context) {
|
|
398
|
+
return visitor.visitBinaryOperatorExpr(this, context);
|
|
399
|
+
}
|
|
400
|
+
clone() {
|
|
401
|
+
return new BinaryOperatorExpr(this.operator, this.lhs.clone(), this.rhs.clone(), this.type, this.sourceSpan);
|
|
402
|
+
}
|
|
403
|
+
isAssignment() {
|
|
404
|
+
const op = this.operator;
|
|
405
|
+
return (op === BinaryOperator.Assign ||
|
|
406
|
+
op === BinaryOperator.AdditionAssignment ||
|
|
407
|
+
op === BinaryOperator.SubtractionAssignment ||
|
|
408
|
+
op === BinaryOperator.MultiplicationAssignment ||
|
|
409
|
+
op === BinaryOperator.DivisionAssignment ||
|
|
410
|
+
op === BinaryOperator.RemainderAssignment ||
|
|
411
|
+
op === BinaryOperator.ExponentiationAssignment ||
|
|
412
|
+
op === BinaryOperator.AndAssignment ||
|
|
413
|
+
op === BinaryOperator.OrAssignment ||
|
|
414
|
+
op === BinaryOperator.NullishCoalesceAssignment);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
class ReadPropExpr extends Expression {
|
|
418
|
+
receiver;
|
|
419
|
+
name;
|
|
420
|
+
constructor(receiver, name, type, sourceSpan) {
|
|
421
|
+
super(type, sourceSpan);
|
|
422
|
+
this.receiver = receiver;
|
|
423
|
+
this.name = name;
|
|
424
|
+
}
|
|
425
|
+
// An alias for name, which allows other logic to handle property reads and keyed reads together.
|
|
426
|
+
get index() {
|
|
427
|
+
return this.name;
|
|
428
|
+
}
|
|
429
|
+
isEquivalent(e) {
|
|
430
|
+
return (e instanceof ReadPropExpr && this.receiver.isEquivalent(e.receiver) && this.name === e.name);
|
|
431
|
+
}
|
|
432
|
+
isConstant() {
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
visitExpression(visitor, context) {
|
|
436
|
+
return visitor.visitReadPropExpr(this, context);
|
|
437
|
+
}
|
|
438
|
+
set(value) {
|
|
439
|
+
return new BinaryOperatorExpr(BinaryOperator.Assign, this.receiver.prop(this.name), value, null, this.sourceSpan);
|
|
440
|
+
}
|
|
441
|
+
clone() {
|
|
442
|
+
return new ReadPropExpr(this.receiver.clone(), this.name, this.type, this.sourceSpan);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
class ReadKeyExpr extends Expression {
|
|
446
|
+
receiver;
|
|
447
|
+
index;
|
|
448
|
+
constructor(receiver, index, type, sourceSpan) {
|
|
449
|
+
super(type, sourceSpan);
|
|
450
|
+
this.receiver = receiver;
|
|
451
|
+
this.index = index;
|
|
452
|
+
}
|
|
453
|
+
isEquivalent(e) {
|
|
454
|
+
return (e instanceof ReadKeyExpr &&
|
|
455
|
+
this.receiver.isEquivalent(e.receiver) &&
|
|
456
|
+
this.index.isEquivalent(e.index));
|
|
457
|
+
}
|
|
458
|
+
isConstant() {
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
visitExpression(visitor, context) {
|
|
462
|
+
return visitor.visitReadKeyExpr(this, context);
|
|
463
|
+
}
|
|
464
|
+
set(value) {
|
|
465
|
+
return new BinaryOperatorExpr(BinaryOperator.Assign, this.receiver.key(this.index), value, null, this.sourceSpan);
|
|
466
|
+
}
|
|
467
|
+
clone() {
|
|
468
|
+
return new ReadKeyExpr(this.receiver.clone(), this.index.clone(), this.type, this.sourceSpan);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
const NULL_EXPR = new LiteralExpr(null, null, null);
|
|
472
|
+
const TYPED_NULL_EXPR = new LiteralExpr(null, INFERRED_TYPE, null);
|
|
473
|
+
//// Statements
|
|
474
|
+
var StmtModifier;
|
|
475
|
+
(function (StmtModifier) {
|
|
476
|
+
StmtModifier[StmtModifier["None"] = 0] = "None";
|
|
477
|
+
StmtModifier[StmtModifier["Final"] = 1] = "Final";
|
|
478
|
+
StmtModifier[StmtModifier["Private"] = 2] = "Private";
|
|
479
|
+
StmtModifier[StmtModifier["Exported"] = 4] = "Exported";
|
|
480
|
+
StmtModifier[StmtModifier["Static"] = 8] = "Static";
|
|
481
|
+
})(StmtModifier || (StmtModifier = {}));
|
|
482
|
+
class Statement {
|
|
483
|
+
modifiers;
|
|
484
|
+
sourceSpan;
|
|
485
|
+
leadingComments;
|
|
486
|
+
constructor(modifiers = StmtModifier.None, sourceSpan = null, leadingComments) {
|
|
487
|
+
this.modifiers = modifiers;
|
|
488
|
+
this.sourceSpan = sourceSpan;
|
|
489
|
+
this.leadingComments = leadingComments;
|
|
490
|
+
}
|
|
491
|
+
hasModifier(modifier) {
|
|
492
|
+
return (this.modifiers & modifier) !== 0;
|
|
493
|
+
}
|
|
494
|
+
addLeadingComment(leadingComment) {
|
|
495
|
+
this.leadingComments = this.leadingComments ?? [];
|
|
496
|
+
this.leadingComments.push(leadingComment);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
class ExpressionStatement extends Statement {
|
|
500
|
+
expr;
|
|
501
|
+
constructor(expr, sourceSpan, leadingComments) {
|
|
502
|
+
super(StmtModifier.None, sourceSpan, leadingComments);
|
|
503
|
+
this.expr = expr;
|
|
504
|
+
}
|
|
505
|
+
isEquivalent(stmt) {
|
|
506
|
+
return stmt instanceof ExpressionStatement && this.expr.isEquivalent(stmt.expr);
|
|
507
|
+
}
|
|
508
|
+
visitStatement(visitor, context) {
|
|
509
|
+
return visitor.visitExpressionStmt(this, context);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
80
513
|
/**
|
|
81
514
|
* Detects `spyOn(dirInstance, 'myInput')` calls that likely modify
|
|
82
515
|
* the input signal. There is no way to change the value inside the input signal,
|
|
@@ -135,8 +568,8 @@ function checkIncompatiblePatterns(inheritanceGraph, checker, groupedTsAstVisito
|
|
|
135
568
|
const spyOnPattern = new SpyOnFieldPattern(checker, fields);
|
|
136
569
|
const visitor = (node) => {
|
|
137
570
|
// Check for manual class instantiations.
|
|
138
|
-
if (ts.isNewExpression(node) && ts.isIdentifier(
|
|
139
|
-
let newTarget = checker.getSymbolAtLocation(
|
|
571
|
+
if (ts.isNewExpression(node) && ts.isIdentifier(migrations.unwrapExpression(node.expression))) {
|
|
572
|
+
let newTarget = checker.getSymbolAtLocation(migrations.unwrapExpression(node.expression));
|
|
140
573
|
// Plain identifier references can point to alias symbols (e.g. imports).
|
|
141
574
|
if (newTarget !== undefined && newTarget.flags & ts.SymbolFlags.Alias) {
|
|
142
575
|
newTarget = checker.getAliasedSymbol(newTarget);
|
|
@@ -155,7 +588,7 @@ function checkIncompatiblePatterns(inheritanceGraph, checker, groupedTsAstVisito
|
|
|
155
588
|
problematicReferencesCheck: if (insidePropertyDeclaration !== null &&
|
|
156
589
|
ts.isIdentifier(node) &&
|
|
157
590
|
insidePropertyDeclaration.parent.heritageClauses !== undefined) {
|
|
158
|
-
let newTarget = checker.getSymbolAtLocation(
|
|
591
|
+
let newTarget = checker.getSymbolAtLocation(migrations.unwrapExpression(node));
|
|
159
592
|
// Plain identifier references can point to alias symbols (e.g. imports).
|
|
160
593
|
if (newTarget !== undefined && newTarget.flags & ts.SymbolFlags.Alias) {
|
|
161
594
|
newTarget = checker.getAliasedSymbol(newTarget);
|
|
@@ -384,7 +817,7 @@ function checkInheritanceOfKnownFields(inheritanceGraph, metaRegistry, fields, o
|
|
|
384
817
|
if (metaRegistry !== null) {
|
|
385
818
|
for (const derivedClasses of inheritanceGraph.traceDerivedClasses(inputClass)) {
|
|
386
819
|
const derivedMeta = ts.isClassDeclaration(derivedClasses) && derivedClasses.name !== undefined
|
|
387
|
-
? metaRegistry.getDirectiveMetadata(new
|
|
820
|
+
? metaRegistry.getDirectiveMetadata(new migrations.Reference(derivedClasses))
|
|
388
821
|
: null;
|
|
389
822
|
if (derivedMeta !== null && derivedMeta.inputFieldNamesFromMetadataArray !== null) {
|
|
390
823
|
derivedMeta.inputFieldNamesFromMetadataArray.forEach((b) => inputFieldNamesFromMetadataArray.add(b));
|
|
@@ -430,18 +863,6 @@ function checkInheritanceOfKnownFields(inheritanceGraph, metaRegistry, fields, o
|
|
|
430
863
|
}
|
|
431
864
|
}
|
|
432
865
|
|
|
433
|
-
function removeFromUnionIfPossible(union, filter) {
|
|
434
|
-
const filtered = union.types.filter(filter);
|
|
435
|
-
if (filtered.length === union.types.length) {
|
|
436
|
-
return union;
|
|
437
|
-
}
|
|
438
|
-
// If there is only item at this point, avoid the union structure.
|
|
439
|
-
if (filtered.length === 1) {
|
|
440
|
-
return filtered[0];
|
|
441
|
-
}
|
|
442
|
-
return ts.factory.updateUnionTypeNode(union, ts.factory.createNodeArray(filtered));
|
|
443
|
-
}
|
|
444
|
-
|
|
445
866
|
/**
|
|
446
867
|
* Inserts a leading string for the given node, respecting
|
|
447
868
|
* indentation of the given anchor node.
|
|
@@ -482,6 +903,18 @@ function cutStringToLineLimit(str, limit) {
|
|
|
482
903
|
return chunks;
|
|
483
904
|
}
|
|
484
905
|
|
|
906
|
+
function removeFromUnionIfPossible(union, filter) {
|
|
907
|
+
const filtered = union.types.filter(filter);
|
|
908
|
+
if (filtered.length === union.types.length) {
|
|
909
|
+
return union;
|
|
910
|
+
}
|
|
911
|
+
// If there is only item at this point, avoid the union structure.
|
|
912
|
+
if (filtered.length === 1) {
|
|
913
|
+
return filtered[0];
|
|
914
|
+
}
|
|
915
|
+
return ts.factory.updateUnionTypeNode(union, ts.factory.createNodeArray(filtered));
|
|
916
|
+
}
|
|
917
|
+
|
|
485
918
|
/**
|
|
486
919
|
* Gets human-readable message information for the given field incompatibility.
|
|
487
920
|
* This text will be used by the language service, or CLI-based migration.
|
|
@@ -1350,6 +1783,18 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1350
1783
|
if (ts.isArrowFunction(parent) && !ts.isBlock(parent.body)) {
|
|
1351
1784
|
replacements.push(...createNewBlockToInsertVariable(parent, filePath, temporaryVariableStr));
|
|
1352
1785
|
}
|
|
1786
|
+
else if (shouldInsertAtMethodStart(reference, recommendedNode, referenceNodeInBlock)) {
|
|
1787
|
+
const blockNode = recommendedNode;
|
|
1788
|
+
const firstStatement = blockNode.statements[0];
|
|
1789
|
+
const leadingSpace = firstStatement
|
|
1790
|
+
? ts.getLineAndCharacterOfPosition(sf, firstStatement.getStart())
|
|
1791
|
+
: ts.getLineAndCharacterOfPosition(sf, referenceNodeInBlock.getStart());
|
|
1792
|
+
replacements.push(new project_paths.Replacement(filePath, new project_paths.TextUpdate({
|
|
1793
|
+
position: firstStatement.getStart(),
|
|
1794
|
+
end: firstStatement.getStart(),
|
|
1795
|
+
toInsert: `${temporaryVariableStr}\n${' '.repeat(leadingSpace.character)}`,
|
|
1796
|
+
})));
|
|
1797
|
+
}
|
|
1353
1798
|
else {
|
|
1354
1799
|
const leadingSpace = ts.getLineAndCharacterOfPosition(sf, referenceNodeInBlock.getStart());
|
|
1355
1800
|
replacements.push(new project_paths.Replacement(filePath, new project_paths.TextUpdate({
|
|
@@ -1366,6 +1811,36 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1366
1811
|
}
|
|
1367
1812
|
}
|
|
1368
1813
|
}
|
|
1814
|
+
/**
|
|
1815
|
+
* Determines if a temporary variable should be inserted at the start of a method.
|
|
1816
|
+
*
|
|
1817
|
+
* This function performs several checks to ensure it's safe to insert a temporary variable:
|
|
1818
|
+
* 1. Verifies the recommended node is a method declaration block
|
|
1819
|
+
* 2. Ensures all references are contained within the method body
|
|
1820
|
+
* 3. Confirms the reference node is the first statement in the method
|
|
1821
|
+
* 4. Validates the reference node is an expression statement with an assignment operation
|
|
1822
|
+
*/
|
|
1823
|
+
function shouldInsertAtMethodStart(references, recommendedNode, referenceNodeInBlock) {
|
|
1824
|
+
if (!ts.isBlock(recommendedNode) || !ts.isMethodDeclaration(recommendedNode.parent)) {
|
|
1825
|
+
return false;
|
|
1826
|
+
}
|
|
1827
|
+
const methodBody = recommendedNode;
|
|
1828
|
+
const allReferencesInMethod = references.accesses.every((access) => {
|
|
1829
|
+
let current = access;
|
|
1830
|
+
while (current && current !== methodBody) {
|
|
1831
|
+
current = current.parent;
|
|
1832
|
+
}
|
|
1833
|
+
return current === methodBody;
|
|
1834
|
+
});
|
|
1835
|
+
if (!allReferencesInMethod) {
|
|
1836
|
+
return false;
|
|
1837
|
+
}
|
|
1838
|
+
return (methodBody.statements.length > 0 &&
|
|
1839
|
+
ts.isExpressionStatement(referenceNodeInBlock) &&
|
|
1840
|
+
methodBody.statements[0] === referenceNodeInBlock &&
|
|
1841
|
+
ts.isBinaryExpression(referenceNodeInBlock.expression) &&
|
|
1842
|
+
referenceNodeInBlock.expression.operatorToken.kind === ts.SyntaxKind.EqualsToken);
|
|
1843
|
+
}
|
|
1369
1844
|
|
|
1370
1845
|
/**
|
|
1371
1846
|
* Migrates TypeScript input references to be signal compatible.
|
|
@@ -1479,6 +1954,7 @@ function migrateTypeScriptTypeReferences(host, references, importManager, info)
|
|
|
1479
1954
|
|
|
1480
1955
|
exports.GroupedTsAstVisitor = GroupedTsAstVisitor;
|
|
1481
1956
|
exports.InheritanceGraph = InheritanceGraph;
|
|
1957
|
+
exports.NULL_EXPR = NULL_EXPR;
|
|
1482
1958
|
exports.checkIncompatiblePatterns = checkIncompatiblePatterns;
|
|
1483
1959
|
exports.checkInheritanceOfKnownFields = checkInheritanceOfKnownFields;
|
|
1484
1960
|
exports.cutStringToLineLimit = cutStringToLineLimit;
|