@angular/core 19.2.1 → 19.2.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 +343 -1640
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/di.mjs +1 -1
- package/fesm2022/primitives/di.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +2 -589
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +26 -10
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +7 -11
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +115 -130
- 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 +14320 -15103
- package/navigation_types.d-u4EOrrdZ.d.ts +121 -0
- package/package.json +1 -1
- package/primitives/di/index.d.ts +65 -59
- package/primitives/event-dispatch/index.d.ts +205 -309
- package/primitives/signals/index.d.ts +158 -195
- package/rxjs-interop/index.d.ts +72 -91
- package/schematics/bundles/{apply_import_manager-b8d6885d.js → apply_import_manager-BynuozbO.js} +12 -16
- package/schematics/bundles/{checker-89987c98.js → checker-DP-zos5Q.js} +2959 -1054
- package/schematics/bundles/cleanup-unused-imports.js +21 -27
- package/schematics/bundles/{compiler_host-2398e4ca.js → compiler_host-DzM2hemp.js} +19 -23
- package/schematics/bundles/control-flow-migration.js +81 -38
- package/schematics/bundles/explicit-standalone-flag.js +26 -32
- package/schematics/bundles/{imports-047fbbc8.js → imports-CIX-JgAN.js} +9 -14
- package/schematics/bundles/{index-10911843.js → index-BPqwMr5d.js} +4 -4
- package/schematics/bundles/{index-e0b2e4a7.js → index-CPpyW--c.js} +55 -59
- package/schematics/bundles/inject-migration.js +121 -127
- package/schematics/bundles/{leading_space-f8944434.js → leading_space-D9nQ8UQC.js} +1 -1
- package/schematics/bundles/{migrate_ts_type_references-52508cd4.js → migrate_ts_type_references-Ri-K4P_1.js} +106 -111
- package/schematics/bundles/{ng_decorators-b0d8b324.js → ng_decorators-DznZ5jMl.js} +4 -8
- package/schematics/bundles/{nodes-7758dbf6.js → nodes-B16H9JUd.js} +2 -6
- package/schematics/bundles/output-migration.js +39 -45
- package/schematics/bundles/pending-tasks.js +13 -19
- package/schematics/bundles/{program-0e1d4f10.js → program-BmLi-Vxz.js} +788 -2631
- package/schematics/bundles/{project_paths-c48796dd.js → project_paths-CXXqWSoY.js} +25 -23
- package/schematics/bundles/{project_tsconfig_paths-b558633b.js → project_tsconfig_paths-CDVxT6Ov.js} +1 -1
- package/schematics/bundles/{property_name-ac18447e.js → property_name-BBwFuqMe.js} +3 -7
- package/schematics/bundles/provide-initializer.js +13 -19
- package/schematics/bundles/route-lazy-loading.js +35 -41
- package/schematics/bundles/self-closing-tags-migration.js +19 -25
- package/schematics/bundles/signal-input-migration.js +60 -67
- package/schematics/bundles/signal-queries-migration.js +47 -54
- package/schematics/bundles/signals.js +9 -11
- package/schematics/bundles/standalone-migration.js +178 -184
- package/testing/index.d.ts +289 -462
- package/weak_ref.d-ttyj86RV.d.ts +9 -0
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.2.
|
|
3
|
+
* @license Angular v19.2.3
|
|
4
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-DP-zos5Q.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-CPpyW--c.js');
|
|
14
|
+
var project_paths = require('./project_paths-CXXqWSoY.js');
|
|
15
|
+
var leading_space = require('./leading_space-D9nQ8UQC.js');
|
|
16
|
+
require('./program-BmLi-Vxz.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
|
*
|
|
@@ -555,11 +550,11 @@ class SpyOnFieldPattern {
|
|
|
555
550
|
this.fields = fields;
|
|
556
551
|
}
|
|
557
552
|
detect(node) {
|
|
558
|
-
if (
|
|
559
|
-
|
|
553
|
+
if (ts.isCallExpression(node) &&
|
|
554
|
+
ts.isIdentifier(node.expression) &&
|
|
560
555
|
node.expression.text === 'spyOn' &&
|
|
561
556
|
node.arguments.length === 2 &&
|
|
562
|
-
|
|
557
|
+
ts.isStringLiteralLike(node.arguments[1])) {
|
|
563
558
|
const spyTargetType = this.checker.getTypeAtLocation(node.arguments[0]);
|
|
564
559
|
const spyProperty = spyTargetType.getProperty(node.arguments[1].text);
|
|
565
560
|
if (spyProperty === undefined) {
|
|
@@ -591,19 +586,19 @@ function checkIncompatiblePatterns(inheritanceGraph, checker$1, groupedTsAstVisi
|
|
|
591
586
|
const inputClassSymbolsToClass = new Map();
|
|
592
587
|
for (const knownFieldClass of getAllClassesWithKnownFields()) {
|
|
593
588
|
const classSymbol = checker$1.getTypeAtLocation(knownFieldClass).symbol;
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
589
|
+
assert(classSymbol != null, 'Expected a symbol to exist for the container of known field class.');
|
|
590
|
+
assert(classSymbol.valueDeclaration !== undefined, 'Expected declaration to exist for known field class.');
|
|
591
|
+
assert(ts.isClassDeclaration(classSymbol.valueDeclaration), 'Expected declaration to be a class.');
|
|
597
592
|
// track class symbol for derived class checks.
|
|
598
593
|
inputClassSymbolsToClass.set(classSymbol, classSymbol.valueDeclaration);
|
|
599
594
|
}
|
|
600
595
|
const spyOnPattern = new SpyOnFieldPattern(checker$1, fields);
|
|
601
596
|
const visitor = (node) => {
|
|
602
597
|
// Check for manual class instantiations.
|
|
603
|
-
if (
|
|
598
|
+
if (ts.isNewExpression(node) && ts.isIdentifier(checker.unwrapExpression(node.expression))) {
|
|
604
599
|
let newTarget = checker$1.getSymbolAtLocation(checker.unwrapExpression(node.expression));
|
|
605
600
|
// Plain identifier references can point to alias symbols (e.g. imports).
|
|
606
|
-
if (newTarget !== undefined && newTarget.flags &
|
|
601
|
+
if (newTarget !== undefined && newTarget.flags & ts.SymbolFlags.Alias) {
|
|
607
602
|
newTarget = checker$1.getAliasedSymbol(newTarget);
|
|
608
603
|
}
|
|
609
604
|
if (newTarget && inputClassSymbolsToClass.has(newTarget)) {
|
|
@@ -618,11 +613,11 @@ function checkIncompatiblePatterns(inheritanceGraph, checker$1, groupedTsAstVisi
|
|
|
618
613
|
// class inherits a non-input member with the same name.
|
|
619
614
|
// Suddenly the derived class changes its signature, but the base class may not.
|
|
620
615
|
problematicReferencesCheck: if (insidePropertyDeclaration !== null &&
|
|
621
|
-
|
|
616
|
+
ts.isIdentifier(node) &&
|
|
622
617
|
insidePropertyDeclaration.parent.heritageClauses !== undefined) {
|
|
623
618
|
let newTarget = checker$1.getSymbolAtLocation(checker.unwrapExpression(node));
|
|
624
619
|
// Plain identifier references can point to alias symbols (e.g. imports).
|
|
625
|
-
if (newTarget !== undefined && newTarget.flags &
|
|
620
|
+
if (newTarget !== undefined && newTarget.flags & ts.SymbolFlags.Alias) {
|
|
626
621
|
newTarget = checker$1.getAliasedSymbol(newTarget);
|
|
627
622
|
}
|
|
628
623
|
if (newTarget && inputClassSymbolsToClass.has(newTarget)) {
|
|
@@ -748,19 +743,19 @@ class InheritanceGraph {
|
|
|
748
743
|
expensivePopulate(files) {
|
|
749
744
|
for (const file of files) {
|
|
750
745
|
const visitor = (node) => {
|
|
751
|
-
if ((
|
|
746
|
+
if ((ts.isClassLike(node) || ts.isInterfaceDeclaration(node)) &&
|
|
752
747
|
node.heritageClauses !== undefined) {
|
|
753
748
|
const heritageTypes = getInheritedTypes(node, this.checker);
|
|
754
749
|
const parents = heritageTypes
|
|
755
750
|
// Interfaces participate in the graph and are not "value declarations".
|
|
756
751
|
// Also, symbol may be undefined for unresolvable nodes.
|
|
757
752
|
.map((t) => (t.symbol ? t.symbol.declarations?.[0] : undefined))
|
|
758
|
-
.filter((d) => d !== undefined && (
|
|
753
|
+
.filter((d) => d !== undefined && (ts.isClassLike(d) || ts.isInterfaceDeclaration(d)));
|
|
759
754
|
this.registerClass(node, parents);
|
|
760
755
|
}
|
|
761
|
-
|
|
756
|
+
ts.forEachChild(node, visitor);
|
|
762
757
|
};
|
|
763
|
-
|
|
758
|
+
ts.forEachChild(file, visitor);
|
|
764
759
|
}
|
|
765
760
|
return this;
|
|
766
761
|
}
|
|
@@ -794,17 +789,17 @@ class GroupedTsAstVisitor {
|
|
|
794
789
|
for (const v of this.visitors) {
|
|
795
790
|
v(node);
|
|
796
791
|
}
|
|
797
|
-
if (
|
|
792
|
+
if (ts.isPropertyDeclaration(node)) {
|
|
798
793
|
this.state.insidePropertyDeclaration = node;
|
|
799
|
-
|
|
794
|
+
ts.forEachChild(node, visitor);
|
|
800
795
|
this.state.insidePropertyDeclaration = null;
|
|
801
796
|
}
|
|
802
797
|
else {
|
|
803
|
-
|
|
798
|
+
ts.forEachChild(node, visitor);
|
|
804
799
|
}
|
|
805
800
|
};
|
|
806
801
|
for (const file of this.files) {
|
|
807
|
-
|
|
802
|
+
ts.forEachChild(file, visitor);
|
|
808
803
|
}
|
|
809
804
|
for (const doneFn of this.doneFns) {
|
|
810
805
|
doneFn();
|
|
@@ -834,13 +829,13 @@ class GroupedTsAstVisitor {
|
|
|
834
829
|
* would then have other derived classes as well, it would propagate the status.
|
|
835
830
|
*/
|
|
836
831
|
function checkInheritanceOfKnownFields(inheritanceGraph, metaRegistry, fields, opts) {
|
|
837
|
-
const allInputClasses = Array.from(inheritanceGraph.allClassesInInheritance).filter((t) =>
|
|
832
|
+
const allInputClasses = Array.from(inheritanceGraph.allClassesInInheritance).filter((t) => ts.isClassDeclaration(t) && opts.isClassWithKnownFields(t));
|
|
838
833
|
for (const inputClass of allInputClasses) {
|
|
839
834
|
// Note: Class parents of `inputClass` were already checked by
|
|
840
835
|
// the previous iterations (given the reverse topological sort)—
|
|
841
836
|
// hence it's safe to assume that incompatibility of parent classes will
|
|
842
837
|
// not change again, at a later time.
|
|
843
|
-
|
|
838
|
+
assert(ts.isClassDeclaration(inputClass), 'Expected input graph node to be always a class.');
|
|
844
839
|
const classFields = opts.getFieldsForClass(inputClass);
|
|
845
840
|
const inputFieldNamesFromMetadataArray = new Set();
|
|
846
841
|
// Iterate through derived class chains and determine all inputs that are overridden
|
|
@@ -848,7 +843,7 @@ function checkInheritanceOfKnownFields(inheritanceGraph, metaRegistry, fields, o
|
|
|
848
843
|
// potential similar class input as incompatible— because those cannot be migrated.
|
|
849
844
|
if (metaRegistry !== null) {
|
|
850
845
|
for (const derivedClasses of inheritanceGraph.traceDerivedClasses(inputClass)) {
|
|
851
|
-
const derivedMeta =
|
|
846
|
+
const derivedMeta = ts.isClassDeclaration(derivedClasses) && derivedClasses.name !== undefined
|
|
852
847
|
? metaRegistry.getDirectiveMetadata(new checker.Reference(derivedClasses))
|
|
853
848
|
: null;
|
|
854
849
|
if (derivedMeta !== null && derivedMeta.inputFieldNamesFromMetadataArray !== null) {
|
|
@@ -863,7 +858,7 @@ function checkInheritanceOfKnownFields(inheritanceGraph, metaRegistry, fields, o
|
|
|
863
858
|
// If we discover a derived, input re-declared via class metadata, then it
|
|
864
859
|
// will cause conflicts as we cannot migrate it/ nor mark it as signal-based.
|
|
865
860
|
if (fieldDescr.node.name !== undefined &&
|
|
866
|
-
(
|
|
861
|
+
(ts.isIdentifier(fieldDescr.node.name) || ts.isStringLiteralLike(fieldDescr.node.name)) &&
|
|
867
862
|
inputFieldNamesFromMetadataArray.has(fieldDescr.node.name.text)) {
|
|
868
863
|
fields.captureUnknownDerivedField(fieldDescr);
|
|
869
864
|
}
|
|
@@ -904,7 +899,7 @@ function removeFromUnionIfPossible(union, filter) {
|
|
|
904
899
|
if (filtered.length === 1) {
|
|
905
900
|
return filtered[0];
|
|
906
901
|
}
|
|
907
|
-
return
|
|
902
|
+
return ts.factory.updateUnionTypeNode(union, ts.factory.createNodeArray(filtered));
|
|
908
903
|
}
|
|
909
904
|
|
|
910
905
|
/**
|
|
@@ -1107,7 +1102,7 @@ const ReservedMarker = Symbol();
|
|
|
1107
1102
|
*/
|
|
1108
1103
|
function isIdentifierFreeInScope(name, location) {
|
|
1109
1104
|
const startContainer = findClosestParentLocalsContainer(location);
|
|
1110
|
-
|
|
1105
|
+
assert(startContainer !== undefined, 'Expecting a locals container.');
|
|
1111
1106
|
// Traverse up and check for potential collisions.
|
|
1112
1107
|
let container = startContainer;
|
|
1113
1108
|
let firstNextContainer = undefined;
|
|
@@ -1134,7 +1129,7 @@ function isIdentifierFreeInScope(name, location) {
|
|
|
1134
1129
|
}
|
|
1135
1130
|
/** Finds the closest parent locals container. */
|
|
1136
1131
|
function findClosestParentLocalsContainer(node) {
|
|
1137
|
-
return
|
|
1132
|
+
return ts.findAncestor(node, isLocalsContainer);
|
|
1138
1133
|
}
|
|
1139
1134
|
/** Whether the given identifier is free in the given locals container. */
|
|
1140
1135
|
function isIdentifierFreeInContainer(name, container) {
|
|
@@ -1146,7 +1141,7 @@ function isIdentifierFreeInContainer(name, container) {
|
|
|
1146
1141
|
// typescript/stable/src/compiler/emitter.ts;l=5436;rcl=651008033
|
|
1147
1142
|
const local = container.locals.get(name);
|
|
1148
1143
|
return (local !== ReservedMarker &&
|
|
1149
|
-
!(local.flags & (
|
|
1144
|
+
!(local.flags & (ts.SymbolFlags.Value | ts.SymbolFlags.ExportValue | ts.SymbolFlags.Alias)));
|
|
1150
1145
|
}
|
|
1151
1146
|
/**
|
|
1152
1147
|
* Whether the given node can contain local variables.
|
|
@@ -1156,36 +1151,36 @@ function isIdentifierFreeInContainer(name, container) {
|
|
|
1156
1151
|
*/
|
|
1157
1152
|
function isLocalsContainer(node) {
|
|
1158
1153
|
switch (node.kind) {
|
|
1159
|
-
case
|
|
1160
|
-
case
|
|
1161
|
-
case
|
|
1162
|
-
case
|
|
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
|
|
1154
|
+
case ts.SyntaxKind.ArrowFunction:
|
|
1155
|
+
case ts.SyntaxKind.Block:
|
|
1156
|
+
case ts.SyntaxKind.CallSignature:
|
|
1157
|
+
case ts.SyntaxKind.CaseBlock:
|
|
1158
|
+
case ts.SyntaxKind.CatchClause:
|
|
1159
|
+
case ts.SyntaxKind.ClassStaticBlockDeclaration:
|
|
1160
|
+
case ts.SyntaxKind.ConditionalType:
|
|
1161
|
+
case ts.SyntaxKind.Constructor:
|
|
1162
|
+
case ts.SyntaxKind.ConstructorType:
|
|
1163
|
+
case ts.SyntaxKind.ConstructSignature:
|
|
1164
|
+
case ts.SyntaxKind.ForStatement:
|
|
1165
|
+
case ts.SyntaxKind.ForInStatement:
|
|
1166
|
+
case ts.SyntaxKind.ForOfStatement:
|
|
1167
|
+
case ts.SyntaxKind.FunctionDeclaration:
|
|
1168
|
+
case ts.SyntaxKind.FunctionExpression:
|
|
1169
|
+
case ts.SyntaxKind.FunctionType:
|
|
1170
|
+
case ts.SyntaxKind.GetAccessor:
|
|
1171
|
+
case ts.SyntaxKind.IndexSignature:
|
|
1172
|
+
case ts.SyntaxKind.JSDocCallbackTag:
|
|
1173
|
+
case ts.SyntaxKind.JSDocEnumTag:
|
|
1174
|
+
case ts.SyntaxKind.JSDocFunctionType:
|
|
1175
|
+
case ts.SyntaxKind.JSDocSignature:
|
|
1176
|
+
case ts.SyntaxKind.JSDocTypedefTag:
|
|
1177
|
+
case ts.SyntaxKind.MappedType:
|
|
1178
|
+
case ts.SyntaxKind.MethodDeclaration:
|
|
1179
|
+
case ts.SyntaxKind.MethodSignature:
|
|
1180
|
+
case ts.SyntaxKind.ModuleDeclaration:
|
|
1181
|
+
case ts.SyntaxKind.SetAccessor:
|
|
1182
|
+
case ts.SyntaxKind.SourceFile:
|
|
1183
|
+
case ts.SyntaxKind.TypeAliasDeclaration:
|
|
1189
1184
|
return true;
|
|
1190
1185
|
default:
|
|
1191
1186
|
return false;
|
|
@@ -1250,8 +1245,8 @@ function createNewBlockToInsertVariable(node, file, toInsert) {
|
|
|
1250
1245
|
// For indentation, we traverse up and find the earliest statement.
|
|
1251
1246
|
// This node is most of the time a good candidate for acceptable
|
|
1252
1247
|
// indentation of a new block.
|
|
1253
|
-
const spacingNode =
|
|
1254
|
-
const { character } =
|
|
1248
|
+
const spacingNode = ts.findAncestor(node, ts.isStatement) ?? node.parent;
|
|
1249
|
+
const { character } = ts.getLineAndCharacterOfPosition(sf, spacingNode.getStart());
|
|
1255
1250
|
const blockSpace = ' '.repeat(character);
|
|
1256
1251
|
const contentSpace = ' '.repeat(character + 2);
|
|
1257
1252
|
return [
|
|
@@ -1301,17 +1296,17 @@ function migrateBindingElementInputReference(tsReferencesInBindingElements, info
|
|
|
1301
1296
|
const sourceFile = bindingElement.getSourceFile();
|
|
1302
1297
|
const file = project_paths.projectFile(sourceFile, info);
|
|
1303
1298
|
const inputFieldName = bindingElement.propertyName ?? bindingElement.name;
|
|
1304
|
-
|
|
1299
|
+
assert(!ts.isObjectBindingPattern(inputFieldName) && !ts.isArrayBindingPattern(inputFieldName), 'Property of binding element cannot be another pattern.');
|
|
1305
1300
|
const tmpName = nameGenerator.generate(reference.text, bindingElement);
|
|
1306
1301
|
// Only use the temporary name, if really needed. A temporary name is needed if
|
|
1307
1302
|
// the input field simply aliased via the binding element, or if the exposed identifier
|
|
1308
1303
|
// is a string-literal like.
|
|
1309
|
-
const useTmpNameForInputField = !
|
|
1304
|
+
const useTmpNameForInputField = !ts.isObjectBindingPattern(bindingElement.name) || !ts.isIdentifier(inputFieldName);
|
|
1310
1305
|
const propertyName = useTmpNameForInputField ? inputFieldName : undefined;
|
|
1311
1306
|
const exposedName = useTmpNameForInputField
|
|
1312
|
-
?
|
|
1307
|
+
? ts.factory.createIdentifier(tmpName)
|
|
1313
1308
|
: inputFieldName;
|
|
1314
|
-
const newBindingToAccessInputField =
|
|
1309
|
+
const newBindingToAccessInputField = ts.factory.updateBindingElement(bindingElement, bindingElement.dotDotDotToken, propertyName, exposedName, bindingElement.initializer);
|
|
1315
1310
|
const temporaryVariableReplacements = insertTemporaryVariableForBindingElement(bindingDecl, file, `const ${bindingElement.name.getText()} = ${exposedName.text}();`);
|
|
1316
1311
|
if (temporaryVariableReplacements === null) {
|
|
1317
1312
|
console.error(`Could not migrate reference ${reference.text} in ${file.rootRelativePath}`);
|
|
@@ -1320,7 +1315,7 @@ function migrateBindingElementInputReference(tsReferencesInBindingElements, info
|
|
|
1320
1315
|
replacements.push(new project_paths.Replacement(file, new project_paths.TextUpdate({
|
|
1321
1316
|
position: bindingElement.getStart(),
|
|
1322
1317
|
end: bindingElement.getEnd(),
|
|
1323
|
-
toInsert: printer.printNode(
|
|
1318
|
+
toInsert: printer.printNode(ts.EmitHint.Unspecified, newBindingToAccessInputField, sourceFile),
|
|
1324
1319
|
})), ...temporaryVariableReplacements);
|
|
1325
1320
|
}
|
|
1326
1321
|
}
|
|
@@ -1337,8 +1332,8 @@ function insertTemporaryVariableForBindingElement(expansionDecl, file, toInsert)
|
|
|
1337
1332
|
// The snippet is simply inserted after the variable declaration.
|
|
1338
1333
|
// The other case of a variable declaration inside a catch clause is handled
|
|
1339
1334
|
// below.
|
|
1340
|
-
if (
|
|
1341
|
-
const leadingSpaceCount =
|
|
1335
|
+
if (ts.isVariableDeclaration(expansionDecl) && ts.isVariableDeclarationList(parent)) {
|
|
1336
|
+
const leadingSpaceCount = ts.getLineAndCharacterOfPosition(sf, parent.getStart()).character;
|
|
1342
1337
|
const leadingSpace = ' '.repeat(leadingSpaceCount);
|
|
1343
1338
|
const statement = parent.parent;
|
|
1344
1339
|
return [
|
|
@@ -1357,7 +1352,7 @@ function insertTemporaryVariableForBindingElement(expansionDecl, file, toInsert)
|
|
|
1357
1352
|
const firstElementInBlock = bodyBlock.statements[0];
|
|
1358
1353
|
const spaceReferenceNode = firstElementInBlock ?? bodyBlock;
|
|
1359
1354
|
const spaceOffset = firstElementInBlock !== undefined ? 0 : 2;
|
|
1360
|
-
const leadingSpaceCount =
|
|
1355
|
+
const leadingSpaceCount = ts.getLineAndCharacterOfPosition(sf, spaceReferenceNode.getStart()).character + spaceOffset;
|
|
1361
1356
|
const leadingSpace = ' '.repeat(leadingSpaceCount);
|
|
1362
1357
|
return [
|
|
1363
1358
|
new project_paths.Replacement(file, new project_paths.TextUpdate({
|
|
@@ -1369,23 +1364,23 @@ function insertTemporaryVariableForBindingElement(expansionDecl, file, toInsert)
|
|
|
1369
1364
|
}
|
|
1370
1365
|
// Other cases where we see an arrow function without a block.
|
|
1371
1366
|
// We need to create one now.
|
|
1372
|
-
if (
|
|
1367
|
+
if (ts.isArrowFunction(parent) && !ts.isBlock(parent.body)) {
|
|
1373
1368
|
return createNewBlockToInsertVariable(parent, file, toInsert);
|
|
1374
1369
|
}
|
|
1375
1370
|
return null;
|
|
1376
1371
|
}
|
|
1377
1372
|
/** Gets the body block of a given node, if available. */
|
|
1378
1373
|
function getBodyBlockOfNode(node) {
|
|
1379
|
-
if ((
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1374
|
+
if ((ts.isMethodDeclaration(node) ||
|
|
1375
|
+
ts.isFunctionDeclaration(node) ||
|
|
1376
|
+
ts.isGetAccessorDeclaration(node) ||
|
|
1377
|
+
ts.isConstructorDeclaration(node) ||
|
|
1378
|
+
ts.isArrowFunction(node)) &&
|
|
1384
1379
|
node.body !== undefined &&
|
|
1385
|
-
|
|
1380
|
+
ts.isBlock(node.body)) {
|
|
1386
1381
|
return node.body;
|
|
1387
1382
|
}
|
|
1388
|
-
if (
|
|
1383
|
+
if (ts.isCatchClause(node.parent)) {
|
|
1389
1384
|
return node.parent.block;
|
|
1390
1385
|
}
|
|
1391
1386
|
return null;
|
|
@@ -1396,25 +1391,25 @@ function getBodyBlockOfNode(node) {
|
|
|
1396
1391
|
* E.g. variables cannot be narrowed when descending into children of `node`.
|
|
1397
1392
|
*/
|
|
1398
1393
|
function isControlFlowBoundary(node) {
|
|
1399
|
-
return ((
|
|
1400
|
-
node.kind ===
|
|
1401
|
-
node.kind ===
|
|
1402
|
-
node.kind ===
|
|
1394
|
+
return ((ts.isFunctionLike(node) && !getImmediatelyInvokedFunctionExpression(node)) ||
|
|
1395
|
+
node.kind === ts.SyntaxKind.ModuleBlock ||
|
|
1396
|
+
node.kind === ts.SyntaxKind.SourceFile ||
|
|
1397
|
+
node.kind === ts.SyntaxKind.PropertyDeclaration);
|
|
1403
1398
|
}
|
|
1404
1399
|
/** Determines the current flow container of a given node. */
|
|
1405
1400
|
function getControlFlowContainer(node) {
|
|
1406
|
-
return
|
|
1401
|
+
return ts.findAncestor(node.parent, (node) => isControlFlowBoundary(node));
|
|
1407
1402
|
}
|
|
1408
1403
|
/** Checks whether the given node refers to an IIFE declaration. */
|
|
1409
1404
|
function getImmediatelyInvokedFunctionExpression(func) {
|
|
1410
|
-
if (func.kind ===
|
|
1405
|
+
if (func.kind === ts.SyntaxKind.FunctionExpression || func.kind === ts.SyntaxKind.ArrowFunction) {
|
|
1411
1406
|
let prev = func;
|
|
1412
1407
|
let parent = func.parent;
|
|
1413
|
-
while (parent.kind ===
|
|
1408
|
+
while (parent.kind === ts.SyntaxKind.ParenthesizedExpression) {
|
|
1414
1409
|
prev = parent;
|
|
1415
1410
|
parent = parent.parent;
|
|
1416
1411
|
}
|
|
1417
|
-
if (parent.kind ===
|
|
1412
|
+
if (parent.kind === ts.SyntaxKind.CallExpression &&
|
|
1418
1413
|
parent.expression === prev) {
|
|
1419
1414
|
return parent;
|
|
1420
1415
|
}
|
|
@@ -1469,10 +1464,10 @@ function traverseFlowForInterestingNodes(flow) {
|
|
|
1469
1464
|
if (flags & FlowFlags.Assignment) {
|
|
1470
1465
|
const assignment = flow;
|
|
1471
1466
|
queue.add(assignment.antecedent);
|
|
1472
|
-
if (
|
|
1467
|
+
if (ts.isVariableDeclaration(assignment.node)) {
|
|
1473
1468
|
interestingNodes.push(assignment.node.name);
|
|
1474
1469
|
}
|
|
1475
|
-
else if (
|
|
1470
|
+
else if (ts.isBindingElement(assignment.node)) {
|
|
1476
1471
|
interestingNodes.push(assignment.node.name);
|
|
1477
1472
|
}
|
|
1478
1473
|
else {
|
|
@@ -1592,7 +1587,7 @@ function analyzeControlFlow(entries, checker) {
|
|
|
1592
1587
|
for (const entry of entries) {
|
|
1593
1588
|
const { flowContainer, resultIndex } = referenceToMetadata.get(entry);
|
|
1594
1589
|
const flowPathInterestingNodes = traverseFlowForInterestingNodes(getFlowNode(entry));
|
|
1595
|
-
|
|
1590
|
+
assert(flowContainer !== null && flowPathInterestingNodes !== null, 'Expected a flow container to exist.');
|
|
1596
1591
|
const narrowPartners = getAllMatchingReferencesInFlowPath(flowPathInterestingNodes, entry, referenceToMetadata, flowContainer, checker);
|
|
1597
1592
|
if (narrowPartners.length !== 0) {
|
|
1598
1593
|
connectSharedReferences(result, narrowPartners, resultIndex);
|
|
@@ -1618,8 +1613,8 @@ function connectSharedReferences(result, flowPartners, refId) {
|
|
|
1618
1613
|
earliestPartnerId = partnerId;
|
|
1619
1614
|
}
|
|
1620
1615
|
}
|
|
1621
|
-
|
|
1622
|
-
|
|
1616
|
+
assert(earliestPartner !== null, 'Expected an earliest partner to be found.');
|
|
1617
|
+
assert(earliestPartnerId !== null, 'Expected an earliest partner to be found.');
|
|
1623
1618
|
// Earliest partner ID could be higher than `refId` in cyclic
|
|
1624
1619
|
// situations like `loop` flow nodes. We need to find the minimum
|
|
1625
1620
|
// and maximum to iterate through partners in between.
|
|
@@ -1660,14 +1655,14 @@ function connectSharedReferences(result, flowPartners, refId) {
|
|
|
1660
1655
|
if (!highestBlock) {
|
|
1661
1656
|
console.error(earliestPartnerId, refId, refFlowContainer.getText(), seenBlocks);
|
|
1662
1657
|
}
|
|
1663
|
-
|
|
1658
|
+
assert(highestBlock, 'Expected a block anchor to be found');
|
|
1664
1659
|
result[earliestPartnerId].recommendedNode = highestBlock;
|
|
1665
1660
|
}
|
|
1666
1661
|
function isPotentialInsertionAncestor(node) {
|
|
1667
1662
|
// Note: Arrow functions may not have a block, but instead use an expression
|
|
1668
1663
|
// directly. This still signifies a "block" as we can convert the concise body
|
|
1669
1664
|
// to a block.
|
|
1670
|
-
return (
|
|
1665
|
+
return (ts.isSourceFile(node) || ts.isBlock(node) || ts.isArrowFunction(node) || ts.isClassLike(node));
|
|
1671
1666
|
}
|
|
1672
1667
|
/**
|
|
1673
1668
|
* Looks through the flow path and interesting nodes to determine which
|
|
@@ -1696,7 +1691,7 @@ function getAllMatchingReferencesInFlowPath(flowPathInterestingNodes, reference,
|
|
|
1696
1691
|
* matches the given reference. If so, returns its flow ID.
|
|
1697
1692
|
*/
|
|
1698
1693
|
function findSimilarReferenceNode(start, reference, referenceToMetadata, restrainingFlowContainer, checker) {
|
|
1699
|
-
return (
|
|
1694
|
+
return (ts.forEachChild(start, function visitChild(node) {
|
|
1700
1695
|
// do not descend into control flow boundaries.
|
|
1701
1696
|
// only references sharing the same container are relevant.
|
|
1702
1697
|
// This is a performance optimization.
|
|
@@ -1704,9 +1699,9 @@ function findSimilarReferenceNode(start, reference, referenceToMetadata, restrai
|
|
|
1704
1699
|
return;
|
|
1705
1700
|
}
|
|
1706
1701
|
// If this is not a potential matching identifier, check its children.
|
|
1707
|
-
if (!
|
|
1702
|
+
if (!ts.isIdentifier(node) ||
|
|
1708
1703
|
referenceToMetadata.get(node)?.flowContainer !== restrainingFlowContainer) {
|
|
1709
|
-
return
|
|
1704
|
+
return ts.forEachChild(node, visitChild);
|
|
1710
1705
|
}
|
|
1711
1706
|
// If this refers to a different instantiation of the input reference,
|
|
1712
1707
|
// continue looking.
|
|
@@ -1724,7 +1719,7 @@ function isLexicalSameReference(checker, sharePartner, reference) {
|
|
|
1724
1719
|
const aParent = index.unwrapParent(reference.parent);
|
|
1725
1720
|
// If the reference is not part a property access, return true. The references
|
|
1726
1721
|
// are guaranteed symbol matches.
|
|
1727
|
-
if (!
|
|
1722
|
+
if (!ts.isPropertyAccessExpression(aParent) && !ts.isElementAccessExpression(aParent)) {
|
|
1728
1723
|
return sharePartner.text === reference.text;
|
|
1729
1724
|
}
|
|
1730
1725
|
// If reference parent is part of a property expression, but the share
|
|
@@ -1774,7 +1769,7 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1774
1769
|
// Extract the shared field name.
|
|
1775
1770
|
const toInsert = idToSharedField.get(recommendedNode);
|
|
1776
1771
|
const replaceNode = index.traverseAccess(originalNode);
|
|
1777
|
-
|
|
1772
|
+
assert(toInsert, 'no shared variable yet available');
|
|
1778
1773
|
replacements.push(new project_paths.Replacement(project_paths.projectFile(sf, info), new project_paths.TextUpdate({
|
|
1779
1774
|
position: replaceNode.getStart(),
|
|
1780
1775
|
end: replaceNode.getEnd(),
|
|
@@ -1800,7 +1795,7 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1800
1795
|
const fieldName = nameGenerator.generate(originalNode.text, referenceNodeInBlock);
|
|
1801
1796
|
let sharedValueAccessExpr;
|
|
1802
1797
|
let temporaryVariableStr;
|
|
1803
|
-
if (
|
|
1798
|
+
if (ts.isClassLike(recommendedNode)) {
|
|
1804
1799
|
sharedValueAccessExpr = `this.${fieldName}`;
|
|
1805
1800
|
temporaryVariableStr = `private readonly ${fieldName} = ${initializer};`;
|
|
1806
1801
|
}
|
|
@@ -1812,11 +1807,11 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1812
1807
|
// If the common ancestor block of all shared references is an arrow function
|
|
1813
1808
|
// without a block, convert the arrow function to a block and insert the temporary
|
|
1814
1809
|
// variable at the beginning.
|
|
1815
|
-
if (
|
|
1810
|
+
if (ts.isArrowFunction(parent) && !ts.isBlock(parent.body)) {
|
|
1816
1811
|
replacements.push(...createNewBlockToInsertVariable(parent, filePath, temporaryVariableStr));
|
|
1817
1812
|
}
|
|
1818
1813
|
else {
|
|
1819
|
-
const leadingSpace =
|
|
1814
|
+
const leadingSpace = ts.getLineAndCharacterOfPosition(sf, referenceNodeInBlock.getStart());
|
|
1820
1815
|
replacements.push(new project_paths.Replacement(filePath, new project_paths.TextUpdate({
|
|
1821
1816
|
position: referenceNodeInBlock.getStart(),
|
|
1822
1817
|
end: referenceNodeInBlock.getStart(),
|
|
@@ -1919,8 +1914,8 @@ function migrateTypeScriptTypeReferences(host, references, importManager, info)
|
|
|
1919
1914
|
}
|
|
1920
1915
|
seenTypeNodes.add(reference.from.node);
|
|
1921
1916
|
if (reference.isPartialReference && reference.isPartOfCatalystFile) {
|
|
1922
|
-
|
|
1923
|
-
|
|
1917
|
+
assert(reference.from.node.typeArguments, 'Expected type arguments for partial reference.');
|
|
1918
|
+
assert(reference.from.node.typeArguments.length === 1, 'Expected an argument for reference.');
|
|
1924
1919
|
const firstArg = reference.from.node.typeArguments[0];
|
|
1925
1920
|
const sf = firstArg.getSourceFile();
|
|
1926
1921
|
// Naive detection of the import. Sufficient for this test file migration.
|
|
@@ -1935,7 +1930,7 @@ function migrateTypeScriptTypeReferences(host, references, importManager, info)
|
|
|
1935
1930
|
host.replacements.push(new project_paths.Replacement(project_paths.projectFile(sf, info), new project_paths.TextUpdate({
|
|
1936
1931
|
position: firstArg.getStart(),
|
|
1937
1932
|
end: firstArg.getStart(),
|
|
1938
|
-
toInsert: `${host.printer.printNode(
|
|
1933
|
+
toInsert: `${host.printer.printNode(ts.EmitHint.Unspecified, unwrapImportExpr, sf)}<`,
|
|
1939
1934
|
})));
|
|
1940
1935
|
host.replacements.push(new project_paths.Replacement(project_paths.projectFile(sf, info), new project_paths.TextUpdate({ position: firstArg.getEnd(), end: firstArg.getEnd(), toInsert: '>' })));
|
|
1941
1936
|
}
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.2.
|
|
3
|
+
* @license Angular v19.2.3
|
|
4
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,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.2.
|
|
3
|
+
* @license Angular v19.2.3
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -8,14 +8,10 @@
|
|
|
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
|
}
|