@angular/core 20.0.0-next.0 → 20.0.0-next.2
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 +3307 -4479
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/di.mjs +45 -0
- package/fesm2022/primitives/di.mjs.map +1 -0
- package/fesm2022/primitives/event-dispatch.mjs +3 -590
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +19 -9
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +8 -33
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +392 -250
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/weak_ref-DrMdAIDh.mjs +12 -0
- package/fesm2022/weak_ref-DrMdAIDh.mjs.map +1 -0
- package/index.d.ts +14339 -15134
- package/navigation_types.d-u4EOrrdZ.d.ts +121 -0
- package/package.json +11 -1
- package/primitives/di/index.d.ts +91 -0
- package/primitives/event-dispatch/index.d.ts +206 -310
- package/primitives/signals/index.d.ts +159 -196
- package/rxjs-interop/index.d.ts +72 -92
- package/schematics/bundles/{apply_import_manager-0959b78c.js → apply_import_manager-CyRT0UvU.js} +13 -17
- package/schematics/bundles/{checker-cf6f7980.js → checker-DF8ZaFW5.js} +3363 -1289
- package/schematics/bundles/cleanup-unused-imports.js +22 -28
- package/schematics/bundles/{compiler_host-cc1379e9.js → compiler_host-Da636uJ8.js} +20 -24
- package/schematics/bundles/control-flow-migration.js +82 -39
- package/schematics/bundles/{imports-31a38653.js → imports-CIX-JgAN.js} +10 -15
- package/schematics/bundles/{index-42d84d69.js → index-DnkWgagp.js} +56 -60
- package/schematics/bundles/{index-6675d6bc.js → index-vGJcp5M7.js} +5 -5
- package/schematics/bundles/inject-flags.js +181 -0
- package/schematics/bundles/inject-migration.js +122 -128
- package/schematics/bundles/{leading_space-6e7a8ec6.js → leading_space-D9nQ8UQC.js} +2 -2
- package/schematics/bundles/{migrate_ts_type_references-5089e4ef.js → migrate_ts_type_references-DtkOnnv0.js} +113 -120
- package/schematics/bundles/{ng_decorators-6878e227.js → ng_decorators-DznZ5jMl.js} +5 -9
- package/schematics/bundles/{nodes-ffdce442.js → nodes-B16H9JUd.js} +3 -7
- package/schematics/bundles/output-migration.js +40 -46
- package/schematics/bundles/{program-362689f0.js → program-BZk27Ndu.js} +846 -2653
- package/schematics/bundles/{project_paths-7d2daa1e.js → project_paths-Jtbi76Bs.js} +26 -24
- package/schematics/bundles/{project_tsconfig_paths-6c9cde78.js → project_tsconfig_paths-CDVxT6Ov.js} +2 -2
- package/schematics/bundles/{property_name-42030525.js → property_name-BBwFuqMe.js} +4 -8
- package/schematics/bundles/route-lazy-loading.js +36 -42
- package/schematics/bundles/self-closing-tags-migration.js +55 -45
- package/schematics/bundles/signal-input-migration.js +61 -68
- package/schematics/bundles/signal-queries-migration.js +48 -55
- package/schematics/bundles/signals.js +10 -12
- package/schematics/bundles/standalone-migration.js +179 -185
- package/schematics/migrations.json +4 -15
- package/testing/index.d.ts +309 -478
- package/weak_ref.d-ttyj86RV.d.ts +9 -0
- package/schematics/bundles/explicit-standalone-flag.js +0 -184
- package/schematics/bundles/pending-tasks.js +0 -103
- package/schematics/bundles/provide-initializer.js +0 -186
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
4
|
-
* (c) 2010-
|
|
3
|
+
* @license Angular v20.0.0-next.2
|
|
4
|
+
* (c) 2010-2025 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-DF8ZaFW5.js');
|
|
10
10
|
var ts = require('typescript');
|
|
11
11
|
require('os');
|
|
12
12
|
var assert = require('assert');
|
|
13
|
-
var index = require('./index-
|
|
14
|
-
var project_paths = require('./project_paths-
|
|
15
|
-
var leading_space = require('./leading_space-
|
|
16
|
-
require('./program-
|
|
13
|
+
var index = require('./index-DnkWgagp.js');
|
|
14
|
+
var project_paths = require('./project_paths-Jtbi76Bs.js');
|
|
15
|
+
var leading_space = require('./leading_space-D9nQ8UQC.js');
|
|
16
|
+
require('./program-BZk27Ndu.js');
|
|
17
17
|
require('path');
|
|
18
18
|
|
|
19
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
-
|
|
21
|
-
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
22
|
-
var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
|
|
23
|
-
|
|
24
19
|
/**
|
|
25
20
|
* Reasons why a field cannot be migrated.
|
|
26
21
|
*
|
|
@@ -239,11 +234,11 @@ class Expression {
|
|
|
239
234
|
and(rhs, sourceSpan) {
|
|
240
235
|
return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan);
|
|
241
236
|
}
|
|
242
|
-
bitwiseOr(rhs, sourceSpan
|
|
243
|
-
return new BinaryOperatorExpr(BinaryOperator.BitwiseOr, this, rhs, null, sourceSpan
|
|
237
|
+
bitwiseOr(rhs, sourceSpan) {
|
|
238
|
+
return new BinaryOperatorExpr(BinaryOperator.BitwiseOr, this, rhs, null, sourceSpan);
|
|
244
239
|
}
|
|
245
|
-
bitwiseAnd(rhs, sourceSpan
|
|
246
|
-
return new BinaryOperatorExpr(BinaryOperator.BitwiseAnd, this, rhs, null, sourceSpan
|
|
240
|
+
bitwiseAnd(rhs, sourceSpan) {
|
|
241
|
+
return new BinaryOperatorExpr(BinaryOperator.BitwiseAnd, this, rhs, null, sourceSpan);
|
|
247
242
|
}
|
|
248
243
|
or(rhs, sourceSpan) {
|
|
249
244
|
return new BinaryOperatorExpr(BinaryOperator.Or, this, rhs, null, sourceSpan);
|
|
@@ -425,13 +420,11 @@ class ConditionalExpr extends Expression {
|
|
|
425
420
|
class BinaryOperatorExpr extends Expression {
|
|
426
421
|
operator;
|
|
427
422
|
rhs;
|
|
428
|
-
parens;
|
|
429
423
|
lhs;
|
|
430
|
-
constructor(operator, lhs, rhs, type, sourceSpan
|
|
424
|
+
constructor(operator, lhs, rhs, type, sourceSpan) {
|
|
431
425
|
super(type || lhs.type, sourceSpan);
|
|
432
426
|
this.operator = operator;
|
|
433
427
|
this.rhs = rhs;
|
|
434
|
-
this.parens = parens;
|
|
435
428
|
this.lhs = lhs;
|
|
436
429
|
}
|
|
437
430
|
isEquivalent(e) {
|
|
@@ -447,7 +440,7 @@ class BinaryOperatorExpr extends Expression {
|
|
|
447
440
|
return visitor.visitBinaryOperatorExpr(this, context);
|
|
448
441
|
}
|
|
449
442
|
clone() {
|
|
450
|
-
return new BinaryOperatorExpr(this.operator, this.lhs.clone(), this.rhs.clone(), this.type, this.sourceSpan
|
|
443
|
+
return new BinaryOperatorExpr(this.operator, this.lhs.clone(), this.rhs.clone(), this.type, this.sourceSpan);
|
|
451
444
|
}
|
|
452
445
|
}
|
|
453
446
|
class ReadPropExpr extends Expression {
|
|
@@ -559,11 +552,11 @@ class SpyOnFieldPattern {
|
|
|
559
552
|
this.fields = fields;
|
|
560
553
|
}
|
|
561
554
|
detect(node) {
|
|
562
|
-
if (
|
|
563
|
-
|
|
555
|
+
if (ts.isCallExpression(node) &&
|
|
556
|
+
ts.isIdentifier(node.expression) &&
|
|
564
557
|
node.expression.text === 'spyOn' &&
|
|
565
558
|
node.arguments.length === 2 &&
|
|
566
|
-
|
|
559
|
+
ts.isStringLiteralLike(node.arguments[1])) {
|
|
567
560
|
const spyTargetType = this.checker.getTypeAtLocation(node.arguments[0]);
|
|
568
561
|
const spyProperty = spyTargetType.getProperty(node.arguments[1].text);
|
|
569
562
|
if (spyProperty === undefined) {
|
|
@@ -595,19 +588,19 @@ function checkIncompatiblePatterns(inheritanceGraph, checker$1, groupedTsAstVisi
|
|
|
595
588
|
const inputClassSymbolsToClass = new Map();
|
|
596
589
|
for (const knownFieldClass of getAllClassesWithKnownFields()) {
|
|
597
590
|
const classSymbol = checker$1.getTypeAtLocation(knownFieldClass).symbol;
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
591
|
+
assert(classSymbol != null, 'Expected a symbol to exist for the container of known field class.');
|
|
592
|
+
assert(classSymbol.valueDeclaration !== undefined, 'Expected declaration to exist for known field class.');
|
|
593
|
+
assert(ts.isClassDeclaration(classSymbol.valueDeclaration), 'Expected declaration to be a class.');
|
|
601
594
|
// track class symbol for derived class checks.
|
|
602
595
|
inputClassSymbolsToClass.set(classSymbol, classSymbol.valueDeclaration);
|
|
603
596
|
}
|
|
604
597
|
const spyOnPattern = new SpyOnFieldPattern(checker$1, fields);
|
|
605
598
|
const visitor = (node) => {
|
|
606
599
|
// Check for manual class instantiations.
|
|
607
|
-
if (
|
|
600
|
+
if (ts.isNewExpression(node) && ts.isIdentifier(checker.unwrapExpression(node.expression))) {
|
|
608
601
|
let newTarget = checker$1.getSymbolAtLocation(checker.unwrapExpression(node.expression));
|
|
609
602
|
// Plain identifier references can point to alias symbols (e.g. imports).
|
|
610
|
-
if (newTarget !== undefined && newTarget.flags &
|
|
603
|
+
if (newTarget !== undefined && newTarget.flags & ts.SymbolFlags.Alias) {
|
|
611
604
|
newTarget = checker$1.getAliasedSymbol(newTarget);
|
|
612
605
|
}
|
|
613
606
|
if (newTarget && inputClassSymbolsToClass.has(newTarget)) {
|
|
@@ -622,11 +615,11 @@ function checkIncompatiblePatterns(inheritanceGraph, checker$1, groupedTsAstVisi
|
|
|
622
615
|
// class inherits a non-input member with the same name.
|
|
623
616
|
// Suddenly the derived class changes its signature, but the base class may not.
|
|
624
617
|
problematicReferencesCheck: if (insidePropertyDeclaration !== null &&
|
|
625
|
-
|
|
618
|
+
ts.isIdentifier(node) &&
|
|
626
619
|
insidePropertyDeclaration.parent.heritageClauses !== undefined) {
|
|
627
620
|
let newTarget = checker$1.getSymbolAtLocation(checker.unwrapExpression(node));
|
|
628
621
|
// Plain identifier references can point to alias symbols (e.g. imports).
|
|
629
|
-
if (newTarget !== undefined && newTarget.flags &
|
|
622
|
+
if (newTarget !== undefined && newTarget.flags & ts.SymbolFlags.Alias) {
|
|
630
623
|
newTarget = checker$1.getAliasedSymbol(newTarget);
|
|
631
624
|
}
|
|
632
625
|
if (newTarget && inputClassSymbolsToClass.has(newTarget)) {
|
|
@@ -752,19 +745,19 @@ class InheritanceGraph {
|
|
|
752
745
|
expensivePopulate(files) {
|
|
753
746
|
for (const file of files) {
|
|
754
747
|
const visitor = (node) => {
|
|
755
|
-
if ((
|
|
748
|
+
if ((ts.isClassLike(node) || ts.isInterfaceDeclaration(node)) &&
|
|
756
749
|
node.heritageClauses !== undefined) {
|
|
757
750
|
const heritageTypes = getInheritedTypes(node, this.checker);
|
|
758
751
|
const parents = heritageTypes
|
|
759
752
|
// Interfaces participate in the graph and are not "value declarations".
|
|
760
753
|
// Also, symbol may be undefined for unresolvable nodes.
|
|
761
754
|
.map((t) => (t.symbol ? t.symbol.declarations?.[0] : undefined))
|
|
762
|
-
.filter((d) => d !== undefined && (
|
|
755
|
+
.filter((d) => d !== undefined && (ts.isClassLike(d) || ts.isInterfaceDeclaration(d)));
|
|
763
756
|
this.registerClass(node, parents);
|
|
764
757
|
}
|
|
765
|
-
|
|
758
|
+
ts.forEachChild(node, visitor);
|
|
766
759
|
};
|
|
767
|
-
|
|
760
|
+
ts.forEachChild(file, visitor);
|
|
768
761
|
}
|
|
769
762
|
return this;
|
|
770
763
|
}
|
|
@@ -798,17 +791,17 @@ class GroupedTsAstVisitor {
|
|
|
798
791
|
for (const v of this.visitors) {
|
|
799
792
|
v(node);
|
|
800
793
|
}
|
|
801
|
-
if (
|
|
794
|
+
if (ts.isPropertyDeclaration(node)) {
|
|
802
795
|
this.state.insidePropertyDeclaration = node;
|
|
803
|
-
|
|
796
|
+
ts.forEachChild(node, visitor);
|
|
804
797
|
this.state.insidePropertyDeclaration = null;
|
|
805
798
|
}
|
|
806
799
|
else {
|
|
807
|
-
|
|
800
|
+
ts.forEachChild(node, visitor);
|
|
808
801
|
}
|
|
809
802
|
};
|
|
810
803
|
for (const file of this.files) {
|
|
811
|
-
|
|
804
|
+
ts.forEachChild(file, visitor);
|
|
812
805
|
}
|
|
813
806
|
for (const doneFn of this.doneFns) {
|
|
814
807
|
doneFn();
|
|
@@ -838,13 +831,13 @@ class GroupedTsAstVisitor {
|
|
|
838
831
|
* would then have other derived classes as well, it would propagate the status.
|
|
839
832
|
*/
|
|
840
833
|
function checkInheritanceOfKnownFields(inheritanceGraph, metaRegistry, fields, opts) {
|
|
841
|
-
const allInputClasses = Array.from(inheritanceGraph.allClassesInInheritance).filter((t) =>
|
|
834
|
+
const allInputClasses = Array.from(inheritanceGraph.allClassesInInheritance).filter((t) => ts.isClassDeclaration(t) && opts.isClassWithKnownFields(t));
|
|
842
835
|
for (const inputClass of allInputClasses) {
|
|
843
836
|
// Note: Class parents of `inputClass` were already checked by
|
|
844
837
|
// the previous iterations (given the reverse topological sort)—
|
|
845
838
|
// hence it's safe to assume that incompatibility of parent classes will
|
|
846
839
|
// not change again, at a later time.
|
|
847
|
-
|
|
840
|
+
assert(ts.isClassDeclaration(inputClass), 'Expected input graph node to be always a class.');
|
|
848
841
|
const classFields = opts.getFieldsForClass(inputClass);
|
|
849
842
|
const inputFieldNamesFromMetadataArray = new Set();
|
|
850
843
|
// Iterate through derived class chains and determine all inputs that are overridden
|
|
@@ -852,7 +845,7 @@ function checkInheritanceOfKnownFields(inheritanceGraph, metaRegistry, fields, o
|
|
|
852
845
|
// potential similar class input as incompatible— because those cannot be migrated.
|
|
853
846
|
if (metaRegistry !== null) {
|
|
854
847
|
for (const derivedClasses of inheritanceGraph.traceDerivedClasses(inputClass)) {
|
|
855
|
-
const derivedMeta =
|
|
848
|
+
const derivedMeta = ts.isClassDeclaration(derivedClasses) && derivedClasses.name !== undefined
|
|
856
849
|
? metaRegistry.getDirectiveMetadata(new checker.Reference(derivedClasses))
|
|
857
850
|
: null;
|
|
858
851
|
if (derivedMeta !== null && derivedMeta.inputFieldNamesFromMetadataArray !== null) {
|
|
@@ -867,7 +860,7 @@ function checkInheritanceOfKnownFields(inheritanceGraph, metaRegistry, fields, o
|
|
|
867
860
|
// If we discover a derived, input re-declared via class metadata, then it
|
|
868
861
|
// will cause conflicts as we cannot migrate it/ nor mark it as signal-based.
|
|
869
862
|
if (fieldDescr.node.name !== undefined &&
|
|
870
|
-
(
|
|
863
|
+
(ts.isIdentifier(fieldDescr.node.name) || ts.isStringLiteralLike(fieldDescr.node.name)) &&
|
|
871
864
|
inputFieldNamesFromMetadataArray.has(fieldDescr.node.name.text)) {
|
|
872
865
|
fields.captureUnknownDerivedField(fieldDescr);
|
|
873
866
|
}
|
|
@@ -908,7 +901,7 @@ function removeFromUnionIfPossible(union, filter) {
|
|
|
908
901
|
if (filtered.length === 1) {
|
|
909
902
|
return filtered[0];
|
|
910
903
|
}
|
|
911
|
-
return
|
|
904
|
+
return ts.factory.updateUnionTypeNode(union, ts.factory.createNodeArray(filtered));
|
|
912
905
|
}
|
|
913
906
|
|
|
914
907
|
/**
|
|
@@ -1111,7 +1104,7 @@ const ReservedMarker = Symbol();
|
|
|
1111
1104
|
*/
|
|
1112
1105
|
function isIdentifierFreeInScope(name, location) {
|
|
1113
1106
|
const startContainer = findClosestParentLocalsContainer(location);
|
|
1114
|
-
|
|
1107
|
+
assert(startContainer !== undefined, 'Expecting a locals container.');
|
|
1115
1108
|
// Traverse up and check for potential collisions.
|
|
1116
1109
|
let container = startContainer;
|
|
1117
1110
|
let firstNextContainer = undefined;
|
|
@@ -1138,7 +1131,7 @@ function isIdentifierFreeInScope(name, location) {
|
|
|
1138
1131
|
}
|
|
1139
1132
|
/** Finds the closest parent locals container. */
|
|
1140
1133
|
function findClosestParentLocalsContainer(node) {
|
|
1141
|
-
return
|
|
1134
|
+
return ts.findAncestor(node, isLocalsContainer);
|
|
1142
1135
|
}
|
|
1143
1136
|
/** Whether the given identifier is free in the given locals container. */
|
|
1144
1137
|
function isIdentifierFreeInContainer(name, container) {
|
|
@@ -1150,7 +1143,7 @@ function isIdentifierFreeInContainer(name, container) {
|
|
|
1150
1143
|
// typescript/stable/src/compiler/emitter.ts;l=5436;rcl=651008033
|
|
1151
1144
|
const local = container.locals.get(name);
|
|
1152
1145
|
return (local !== ReservedMarker &&
|
|
1153
|
-
!(local.flags & (
|
|
1146
|
+
!(local.flags & (ts.SymbolFlags.Value | ts.SymbolFlags.ExportValue | ts.SymbolFlags.Alias)));
|
|
1154
1147
|
}
|
|
1155
1148
|
/**
|
|
1156
1149
|
* Whether the given node can contain local variables.
|
|
@@ -1160,36 +1153,36 @@ function isIdentifierFreeInContainer(name, container) {
|
|
|
1160
1153
|
*/
|
|
1161
1154
|
function isLocalsContainer(node) {
|
|
1162
1155
|
switch (node.kind) {
|
|
1163
|
-
case
|
|
1164
|
-
case
|
|
1165
|
-
case
|
|
1166
|
-
case
|
|
1167
|
-
case
|
|
1168
|
-
case
|
|
1169
|
-
case
|
|
1170
|
-
case
|
|
1171
|
-
case
|
|
1172
|
-
case
|
|
1173
|
-
case
|
|
1174
|
-
case
|
|
1175
|
-
case
|
|
1176
|
-
case
|
|
1177
|
-
case
|
|
1178
|
-
case
|
|
1179
|
-
case
|
|
1180
|
-
case
|
|
1181
|
-
case
|
|
1182
|
-
case
|
|
1183
|
-
case
|
|
1184
|
-
case
|
|
1185
|
-
case
|
|
1186
|
-
case
|
|
1187
|
-
case
|
|
1188
|
-
case
|
|
1189
|
-
case
|
|
1190
|
-
case
|
|
1191
|
-
case
|
|
1192
|
-
case
|
|
1156
|
+
case ts.SyntaxKind.ArrowFunction:
|
|
1157
|
+
case ts.SyntaxKind.Block:
|
|
1158
|
+
case ts.SyntaxKind.CallSignature:
|
|
1159
|
+
case ts.SyntaxKind.CaseBlock:
|
|
1160
|
+
case ts.SyntaxKind.CatchClause:
|
|
1161
|
+
case ts.SyntaxKind.ClassStaticBlockDeclaration:
|
|
1162
|
+
case ts.SyntaxKind.ConditionalType:
|
|
1163
|
+
case ts.SyntaxKind.Constructor:
|
|
1164
|
+
case ts.SyntaxKind.ConstructorType:
|
|
1165
|
+
case ts.SyntaxKind.ConstructSignature:
|
|
1166
|
+
case ts.SyntaxKind.ForStatement:
|
|
1167
|
+
case ts.SyntaxKind.ForInStatement:
|
|
1168
|
+
case ts.SyntaxKind.ForOfStatement:
|
|
1169
|
+
case ts.SyntaxKind.FunctionDeclaration:
|
|
1170
|
+
case ts.SyntaxKind.FunctionExpression:
|
|
1171
|
+
case ts.SyntaxKind.FunctionType:
|
|
1172
|
+
case ts.SyntaxKind.GetAccessor:
|
|
1173
|
+
case ts.SyntaxKind.IndexSignature:
|
|
1174
|
+
case ts.SyntaxKind.JSDocCallbackTag:
|
|
1175
|
+
case ts.SyntaxKind.JSDocEnumTag:
|
|
1176
|
+
case ts.SyntaxKind.JSDocFunctionType:
|
|
1177
|
+
case ts.SyntaxKind.JSDocSignature:
|
|
1178
|
+
case ts.SyntaxKind.JSDocTypedefTag:
|
|
1179
|
+
case ts.SyntaxKind.MappedType:
|
|
1180
|
+
case ts.SyntaxKind.MethodDeclaration:
|
|
1181
|
+
case ts.SyntaxKind.MethodSignature:
|
|
1182
|
+
case ts.SyntaxKind.ModuleDeclaration:
|
|
1183
|
+
case ts.SyntaxKind.SetAccessor:
|
|
1184
|
+
case ts.SyntaxKind.SourceFile:
|
|
1185
|
+
case ts.SyntaxKind.TypeAliasDeclaration:
|
|
1193
1186
|
return true;
|
|
1194
1187
|
default:
|
|
1195
1188
|
return false;
|
|
@@ -1254,8 +1247,8 @@ function createNewBlockToInsertVariable(node, file, toInsert) {
|
|
|
1254
1247
|
// For indentation, we traverse up and find the earliest statement.
|
|
1255
1248
|
// This node is most of the time a good candidate for acceptable
|
|
1256
1249
|
// indentation of a new block.
|
|
1257
|
-
const spacingNode =
|
|
1258
|
-
const { character } =
|
|
1250
|
+
const spacingNode = ts.findAncestor(node, ts.isStatement) ?? node.parent;
|
|
1251
|
+
const { character } = ts.getLineAndCharacterOfPosition(sf, spacingNode.getStart());
|
|
1259
1252
|
const blockSpace = ' '.repeat(character);
|
|
1260
1253
|
const contentSpace = ' '.repeat(character + 2);
|
|
1261
1254
|
return [
|
|
@@ -1305,17 +1298,17 @@ function migrateBindingElementInputReference(tsReferencesInBindingElements, info
|
|
|
1305
1298
|
const sourceFile = bindingElement.getSourceFile();
|
|
1306
1299
|
const file = project_paths.projectFile(sourceFile, info);
|
|
1307
1300
|
const inputFieldName = bindingElement.propertyName ?? bindingElement.name;
|
|
1308
|
-
|
|
1301
|
+
assert(!ts.isObjectBindingPattern(inputFieldName) && !ts.isArrayBindingPattern(inputFieldName), 'Property of binding element cannot be another pattern.');
|
|
1309
1302
|
const tmpName = nameGenerator.generate(reference.text, bindingElement);
|
|
1310
1303
|
// Only use the temporary name, if really needed. A temporary name is needed if
|
|
1311
1304
|
// the input field simply aliased via the binding element, or if the exposed identifier
|
|
1312
1305
|
// is a string-literal like.
|
|
1313
|
-
const useTmpNameForInputField = !
|
|
1306
|
+
const useTmpNameForInputField = !ts.isObjectBindingPattern(bindingElement.name) || !ts.isIdentifier(inputFieldName);
|
|
1314
1307
|
const propertyName = useTmpNameForInputField ? inputFieldName : undefined;
|
|
1315
1308
|
const exposedName = useTmpNameForInputField
|
|
1316
|
-
?
|
|
1309
|
+
? ts.factory.createIdentifier(tmpName)
|
|
1317
1310
|
: inputFieldName;
|
|
1318
|
-
const newBindingToAccessInputField =
|
|
1311
|
+
const newBindingToAccessInputField = ts.factory.updateBindingElement(bindingElement, bindingElement.dotDotDotToken, propertyName, exposedName, bindingElement.initializer);
|
|
1319
1312
|
const temporaryVariableReplacements = insertTemporaryVariableForBindingElement(bindingDecl, file, `const ${bindingElement.name.getText()} = ${exposedName.text}();`);
|
|
1320
1313
|
if (temporaryVariableReplacements === null) {
|
|
1321
1314
|
console.error(`Could not migrate reference ${reference.text} in ${file.rootRelativePath}`);
|
|
@@ -1324,7 +1317,7 @@ function migrateBindingElementInputReference(tsReferencesInBindingElements, info
|
|
|
1324
1317
|
replacements.push(new project_paths.Replacement(file, new project_paths.TextUpdate({
|
|
1325
1318
|
position: bindingElement.getStart(),
|
|
1326
1319
|
end: bindingElement.getEnd(),
|
|
1327
|
-
toInsert: printer.printNode(
|
|
1320
|
+
toInsert: printer.printNode(ts.EmitHint.Unspecified, newBindingToAccessInputField, sourceFile),
|
|
1328
1321
|
})), ...temporaryVariableReplacements);
|
|
1329
1322
|
}
|
|
1330
1323
|
}
|
|
@@ -1341,8 +1334,8 @@ function insertTemporaryVariableForBindingElement(expansionDecl, file, toInsert)
|
|
|
1341
1334
|
// The snippet is simply inserted after the variable declaration.
|
|
1342
1335
|
// The other case of a variable declaration inside a catch clause is handled
|
|
1343
1336
|
// below.
|
|
1344
|
-
if (
|
|
1345
|
-
const leadingSpaceCount =
|
|
1337
|
+
if (ts.isVariableDeclaration(expansionDecl) && ts.isVariableDeclarationList(parent)) {
|
|
1338
|
+
const leadingSpaceCount = ts.getLineAndCharacterOfPosition(sf, parent.getStart()).character;
|
|
1346
1339
|
const leadingSpace = ' '.repeat(leadingSpaceCount);
|
|
1347
1340
|
const statement = parent.parent;
|
|
1348
1341
|
return [
|
|
@@ -1361,7 +1354,7 @@ function insertTemporaryVariableForBindingElement(expansionDecl, file, toInsert)
|
|
|
1361
1354
|
const firstElementInBlock = bodyBlock.statements[0];
|
|
1362
1355
|
const spaceReferenceNode = firstElementInBlock ?? bodyBlock;
|
|
1363
1356
|
const spaceOffset = firstElementInBlock !== undefined ? 0 : 2;
|
|
1364
|
-
const leadingSpaceCount =
|
|
1357
|
+
const leadingSpaceCount = ts.getLineAndCharacterOfPosition(sf, spaceReferenceNode.getStart()).character + spaceOffset;
|
|
1365
1358
|
const leadingSpace = ' '.repeat(leadingSpaceCount);
|
|
1366
1359
|
return [
|
|
1367
1360
|
new project_paths.Replacement(file, new project_paths.TextUpdate({
|
|
@@ -1373,23 +1366,23 @@ function insertTemporaryVariableForBindingElement(expansionDecl, file, toInsert)
|
|
|
1373
1366
|
}
|
|
1374
1367
|
// Other cases where we see an arrow function without a block.
|
|
1375
1368
|
// We need to create one now.
|
|
1376
|
-
if (
|
|
1369
|
+
if (ts.isArrowFunction(parent) && !ts.isBlock(parent.body)) {
|
|
1377
1370
|
return createNewBlockToInsertVariable(parent, file, toInsert);
|
|
1378
1371
|
}
|
|
1379
1372
|
return null;
|
|
1380
1373
|
}
|
|
1381
1374
|
/** Gets the body block of a given node, if available. */
|
|
1382
1375
|
function getBodyBlockOfNode(node) {
|
|
1383
|
-
if ((
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1376
|
+
if ((ts.isMethodDeclaration(node) ||
|
|
1377
|
+
ts.isFunctionDeclaration(node) ||
|
|
1378
|
+
ts.isGetAccessorDeclaration(node) ||
|
|
1379
|
+
ts.isConstructorDeclaration(node) ||
|
|
1380
|
+
ts.isArrowFunction(node)) &&
|
|
1388
1381
|
node.body !== undefined &&
|
|
1389
|
-
|
|
1382
|
+
ts.isBlock(node.body)) {
|
|
1390
1383
|
return node.body;
|
|
1391
1384
|
}
|
|
1392
|
-
if (
|
|
1385
|
+
if (ts.isCatchClause(node.parent)) {
|
|
1393
1386
|
return node.parent.block;
|
|
1394
1387
|
}
|
|
1395
1388
|
return null;
|
|
@@ -1400,25 +1393,25 @@ function getBodyBlockOfNode(node) {
|
|
|
1400
1393
|
* E.g. variables cannot be narrowed when descending into children of `node`.
|
|
1401
1394
|
*/
|
|
1402
1395
|
function isControlFlowBoundary(node) {
|
|
1403
|
-
return ((
|
|
1404
|
-
node.kind ===
|
|
1405
|
-
node.kind ===
|
|
1406
|
-
node.kind ===
|
|
1396
|
+
return ((ts.isFunctionLike(node) && !getImmediatelyInvokedFunctionExpression(node)) ||
|
|
1397
|
+
node.kind === ts.SyntaxKind.ModuleBlock ||
|
|
1398
|
+
node.kind === ts.SyntaxKind.SourceFile ||
|
|
1399
|
+
node.kind === ts.SyntaxKind.PropertyDeclaration);
|
|
1407
1400
|
}
|
|
1408
1401
|
/** Determines the current flow container of a given node. */
|
|
1409
1402
|
function getControlFlowContainer(node) {
|
|
1410
|
-
return
|
|
1403
|
+
return ts.findAncestor(node.parent, (node) => isControlFlowBoundary(node));
|
|
1411
1404
|
}
|
|
1412
1405
|
/** Checks whether the given node refers to an IIFE declaration. */
|
|
1413
1406
|
function getImmediatelyInvokedFunctionExpression(func) {
|
|
1414
|
-
if (func.kind ===
|
|
1407
|
+
if (func.kind === ts.SyntaxKind.FunctionExpression || func.kind === ts.SyntaxKind.ArrowFunction) {
|
|
1415
1408
|
let prev = func;
|
|
1416
1409
|
let parent = func.parent;
|
|
1417
|
-
while (parent.kind ===
|
|
1410
|
+
while (parent.kind === ts.SyntaxKind.ParenthesizedExpression) {
|
|
1418
1411
|
prev = parent;
|
|
1419
1412
|
parent = parent.parent;
|
|
1420
1413
|
}
|
|
1421
|
-
if (parent.kind ===
|
|
1414
|
+
if (parent.kind === ts.SyntaxKind.CallExpression &&
|
|
1422
1415
|
parent.expression === prev) {
|
|
1423
1416
|
return parent;
|
|
1424
1417
|
}
|
|
@@ -1473,10 +1466,10 @@ function traverseFlowForInterestingNodes(flow) {
|
|
|
1473
1466
|
if (flags & FlowFlags.Assignment) {
|
|
1474
1467
|
const assignment = flow;
|
|
1475
1468
|
queue.add(assignment.antecedent);
|
|
1476
|
-
if (
|
|
1469
|
+
if (ts.isVariableDeclaration(assignment.node)) {
|
|
1477
1470
|
interestingNodes.push(assignment.node.name);
|
|
1478
1471
|
}
|
|
1479
|
-
else if (
|
|
1472
|
+
else if (ts.isBindingElement(assignment.node)) {
|
|
1480
1473
|
interestingNodes.push(assignment.node.name);
|
|
1481
1474
|
}
|
|
1482
1475
|
else {
|
|
@@ -1596,7 +1589,7 @@ function analyzeControlFlow(entries, checker) {
|
|
|
1596
1589
|
for (const entry of entries) {
|
|
1597
1590
|
const { flowContainer, resultIndex } = referenceToMetadata.get(entry);
|
|
1598
1591
|
const flowPathInterestingNodes = traverseFlowForInterestingNodes(getFlowNode(entry));
|
|
1599
|
-
|
|
1592
|
+
assert(flowContainer !== null && flowPathInterestingNodes !== null, 'Expected a flow container to exist.');
|
|
1600
1593
|
const narrowPartners = getAllMatchingReferencesInFlowPath(flowPathInterestingNodes, entry, referenceToMetadata, flowContainer, checker);
|
|
1601
1594
|
if (narrowPartners.length !== 0) {
|
|
1602
1595
|
connectSharedReferences(result, narrowPartners, resultIndex);
|
|
@@ -1622,8 +1615,8 @@ function connectSharedReferences(result, flowPartners, refId) {
|
|
|
1622
1615
|
earliestPartnerId = partnerId;
|
|
1623
1616
|
}
|
|
1624
1617
|
}
|
|
1625
|
-
|
|
1626
|
-
|
|
1618
|
+
assert(earliestPartner !== null, 'Expected an earliest partner to be found.');
|
|
1619
|
+
assert(earliestPartnerId !== null, 'Expected an earliest partner to be found.');
|
|
1627
1620
|
// Earliest partner ID could be higher than `refId` in cyclic
|
|
1628
1621
|
// situations like `loop` flow nodes. We need to find the minimum
|
|
1629
1622
|
// and maximum to iterate through partners in between.
|
|
@@ -1664,14 +1657,14 @@ function connectSharedReferences(result, flowPartners, refId) {
|
|
|
1664
1657
|
if (!highestBlock) {
|
|
1665
1658
|
console.error(earliestPartnerId, refId, refFlowContainer.getText(), seenBlocks);
|
|
1666
1659
|
}
|
|
1667
|
-
|
|
1660
|
+
assert(highestBlock, 'Expected a block anchor to be found');
|
|
1668
1661
|
result[earliestPartnerId].recommendedNode = highestBlock;
|
|
1669
1662
|
}
|
|
1670
1663
|
function isPotentialInsertionAncestor(node) {
|
|
1671
1664
|
// Note: Arrow functions may not have a block, but instead use an expression
|
|
1672
1665
|
// directly. This still signifies a "block" as we can convert the concise body
|
|
1673
1666
|
// to a block.
|
|
1674
|
-
return (
|
|
1667
|
+
return (ts.isSourceFile(node) || ts.isBlock(node) || ts.isArrowFunction(node) || ts.isClassLike(node));
|
|
1675
1668
|
}
|
|
1676
1669
|
/**
|
|
1677
1670
|
* Looks through the flow path and interesting nodes to determine which
|
|
@@ -1700,7 +1693,7 @@ function getAllMatchingReferencesInFlowPath(flowPathInterestingNodes, reference,
|
|
|
1700
1693
|
* matches the given reference. If so, returns its flow ID.
|
|
1701
1694
|
*/
|
|
1702
1695
|
function findSimilarReferenceNode(start, reference, referenceToMetadata, restrainingFlowContainer, checker) {
|
|
1703
|
-
return (
|
|
1696
|
+
return (ts.forEachChild(start, function visitChild(node) {
|
|
1704
1697
|
// do not descend into control flow boundaries.
|
|
1705
1698
|
// only references sharing the same container are relevant.
|
|
1706
1699
|
// This is a performance optimization.
|
|
@@ -1708,9 +1701,9 @@ function findSimilarReferenceNode(start, reference, referenceToMetadata, restrai
|
|
|
1708
1701
|
return;
|
|
1709
1702
|
}
|
|
1710
1703
|
// If this is not a potential matching identifier, check its children.
|
|
1711
|
-
if (!
|
|
1704
|
+
if (!ts.isIdentifier(node) ||
|
|
1712
1705
|
referenceToMetadata.get(node)?.flowContainer !== restrainingFlowContainer) {
|
|
1713
|
-
return
|
|
1706
|
+
return ts.forEachChild(node, visitChild);
|
|
1714
1707
|
}
|
|
1715
1708
|
// If this refers to a different instantiation of the input reference,
|
|
1716
1709
|
// continue looking.
|
|
@@ -1728,7 +1721,7 @@ function isLexicalSameReference(checker, sharePartner, reference) {
|
|
|
1728
1721
|
const aParent = index.unwrapParent(reference.parent);
|
|
1729
1722
|
// If the reference is not part a property access, return true. The references
|
|
1730
1723
|
// are guaranteed symbol matches.
|
|
1731
|
-
if (!
|
|
1724
|
+
if (!ts.isPropertyAccessExpression(aParent) && !ts.isElementAccessExpression(aParent)) {
|
|
1732
1725
|
return sharePartner.text === reference.text;
|
|
1733
1726
|
}
|
|
1734
1727
|
// If reference parent is part of a property expression, but the share
|
|
@@ -1778,7 +1771,7 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1778
1771
|
// Extract the shared field name.
|
|
1779
1772
|
const toInsert = idToSharedField.get(recommendedNode);
|
|
1780
1773
|
const replaceNode = index.traverseAccess(originalNode);
|
|
1781
|
-
|
|
1774
|
+
assert(toInsert, 'no shared variable yet available');
|
|
1782
1775
|
replacements.push(new project_paths.Replacement(project_paths.projectFile(sf, info), new project_paths.TextUpdate({
|
|
1783
1776
|
position: replaceNode.getStart(),
|
|
1784
1777
|
end: replaceNode.getEnd(),
|
|
@@ -1804,7 +1797,7 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1804
1797
|
const fieldName = nameGenerator.generate(originalNode.text, referenceNodeInBlock);
|
|
1805
1798
|
let sharedValueAccessExpr;
|
|
1806
1799
|
let temporaryVariableStr;
|
|
1807
|
-
if (
|
|
1800
|
+
if (ts.isClassLike(recommendedNode)) {
|
|
1808
1801
|
sharedValueAccessExpr = `this.${fieldName}`;
|
|
1809
1802
|
temporaryVariableStr = `private readonly ${fieldName} = ${initializer};`;
|
|
1810
1803
|
}
|
|
@@ -1816,11 +1809,11 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1816
1809
|
// If the common ancestor block of all shared references is an arrow function
|
|
1817
1810
|
// without a block, convert the arrow function to a block and insert the temporary
|
|
1818
1811
|
// variable at the beginning.
|
|
1819
|
-
if (
|
|
1812
|
+
if (ts.isArrowFunction(parent) && !ts.isBlock(parent.body)) {
|
|
1820
1813
|
replacements.push(...createNewBlockToInsertVariable(parent, filePath, temporaryVariableStr));
|
|
1821
1814
|
}
|
|
1822
1815
|
else {
|
|
1823
|
-
const leadingSpace =
|
|
1816
|
+
const leadingSpace = ts.getLineAndCharacterOfPosition(sf, referenceNodeInBlock.getStart());
|
|
1824
1817
|
replacements.push(new project_paths.Replacement(filePath, new project_paths.TextUpdate({
|
|
1825
1818
|
position: referenceNodeInBlock.getStart(),
|
|
1826
1819
|
end: referenceNodeInBlock.getStart(),
|
|
@@ -1923,8 +1916,8 @@ function migrateTypeScriptTypeReferences(host, references, importManager, info)
|
|
|
1923
1916
|
}
|
|
1924
1917
|
seenTypeNodes.add(reference.from.node);
|
|
1925
1918
|
if (reference.isPartialReference && reference.isPartOfCatalystFile) {
|
|
1926
|
-
|
|
1927
|
-
|
|
1919
|
+
assert(reference.from.node.typeArguments, 'Expected type arguments for partial reference.');
|
|
1920
|
+
assert(reference.from.node.typeArguments.length === 1, 'Expected an argument for reference.');
|
|
1928
1921
|
const firstArg = reference.from.node.typeArguments[0];
|
|
1929
1922
|
const sf = firstArg.getSourceFile();
|
|
1930
1923
|
// Naive detection of the import. Sufficient for this test file migration.
|
|
@@ -1939,7 +1932,7 @@ function migrateTypeScriptTypeReferences(host, references, importManager, info)
|
|
|
1939
1932
|
host.replacements.push(new project_paths.Replacement(project_paths.projectFile(sf, info), new project_paths.TextUpdate({
|
|
1940
1933
|
position: firstArg.getStart(),
|
|
1941
1934
|
end: firstArg.getStart(),
|
|
1942
|
-
toInsert: `${host.printer.printNode(
|
|
1935
|
+
toInsert: `${host.printer.printNode(ts.EmitHint.Unspecified, unwrapImportExpr, sf)}<`,
|
|
1943
1936
|
})));
|
|
1944
1937
|
host.replacements.push(new project_paths.Replacement(project_paths.projectFile(sf, info), new project_paths.TextUpdate({ position: firstArg.getEnd(), end: firstArg.getEnd(), toInsert: '>' })));
|
|
1945
1938
|
}
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
4
|
-
* (c) 2010-
|
|
3
|
+
* @license Angular v20.0.0-next.2
|
|
4
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
var ts = require('typescript');
|
|
10
|
-
var imports = require('./imports-
|
|
11
|
-
|
|
12
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
-
|
|
14
|
-
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
10
|
+
var imports = require('./imports-CIX-JgAN.js');
|
|
15
11
|
|
|
16
12
|
function getCallDecoratorImport(typeChecker, decorator) {
|
|
17
13
|
// Note that this does not cover the edge case where decorators are called from
|
|
18
14
|
// a namespace import: e.g. "@core.Component()". This is not handled by Ngtsc either.
|
|
19
|
-
if (!
|
|
20
|
-
!
|
|
15
|
+
if (!ts.isCallExpression(decorator.expression) ||
|
|
16
|
+
!ts.isIdentifier(decorator.expression.expression)) {
|
|
21
17
|
return null;
|
|
22
18
|
}
|
|
23
19
|
const identifier = decorator.expression.expression;
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
4
|
-
* (c) 2010-
|
|
3
|
+
* @license Angular v20.0.0-next.2
|
|
4
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
9
|
var ts = require('typescript');
|
|
10
10
|
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
-
|
|
13
|
-
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
14
|
-
|
|
15
11
|
/** Find the closest parent node of a particular kind. */
|
|
16
12
|
function closestNode(node, predicate) {
|
|
17
13
|
let current = node.parent;
|
|
18
|
-
while (current && !
|
|
14
|
+
while (current && !ts.isSourceFile(current)) {
|
|
19
15
|
if (predicate(current)) {
|
|
20
16
|
return current;
|
|
21
17
|
}
|