@angular/core 20.0.0-next.5 → 20.0.0-next.7
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/{api.d-mxcXqDpA.d.ts → api.d-KjtSQajV.d.ts} +4 -4
- package/{ng_i18n_closure_mode.d-DLxSUiDr.d.ts → chrome_dev_tools_performance.d-qv7drdAl.d.ts} +20 -5
- package/{discovery.d-CyYpOJ7j.d.ts → discovery.d-D6xf1HH-.d.ts} +8 -79
- package/{event_dispatcher.d-PWnbqZDx.d.ts → event_dispatcher.d-DlbccpYq.d.ts} +3 -3
- package/fesm2022/{attribute-B17mgaqe.mjs → attribute-BWp59EjE.mjs} +3 -3
- package/fesm2022/{attribute-B17mgaqe.mjs.map → attribute-BWp59EjE.mjs.map} +1 -1
- package/fesm2022/core.mjs +22 -31
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/{debug_node-xKpCIZm-.mjs → debug_node-B3CixwNH.mjs} +218 -141
- package/fesm2022/debug_node-B3CixwNH.mjs.map +1 -0
- package/fesm2022/primitives/di.mjs +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +2 -2
- package/fesm2022/primitives/signals.mjs +5 -5
- package/fesm2022/{resource-BPpYEDic.mjs → resource-DtpS_sTw.mjs} +6 -8
- package/fesm2022/resource-DtpS_sTw.mjs.map +1 -0
- package/fesm2022/{root_effect_scheduler-D0_b1cf_.mjs → root_effect_scheduler-BK3l7wIO.mjs} +144 -68
- package/fesm2022/root_effect_scheduler-BK3l7wIO.mjs.map +1 -0
- package/fesm2022/rxjs-interop.mjs +7 -84
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/{signal-DhRAAi7R.mjs → signal-B6pMq7KS.mjs} +3 -3
- package/fesm2022/{signal-DhRAAi7R.mjs.map → signal-B6pMq7KS.mjs.map} +1 -1
- package/fesm2022/testing.mjs +167 -103
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/{untracked-DaaW3JJm.mjs → untracked-Bz5WMeU1.mjs} +4 -4
- package/fesm2022/{untracked-DaaW3JJm.mjs.map → untracked-Bz5WMeU1.mjs.map} +1 -1
- package/fesm2022/{weak_ref-DrMdAIDh.mjs → weak_ref-BaIq-pgY.mjs} +3 -3
- package/fesm2022/{weak_ref-DrMdAIDh.mjs.map → weak_ref-BaIq-pgY.mjs.map} +1 -1
- package/{graph.d-StYigYp1.d.ts → graph.d-BcIOep_B.d.ts} +3 -3
- package/index.d.ts +34 -41
- package/package.json +2 -2
- package/primitives/di/index.d.ts +1 -1
- package/primitives/event-dispatch/index.d.ts +3 -3
- package/primitives/signals/index.d.ts +6 -6
- package/rxjs-interop/index.d.ts +8 -17
- package/schematics/bundles/{apply_import_manager-C-ysxahq.js → apply_import_manager-DczRKpTm.js} +6 -6
- package/schematics/bundles/{change_tracker-0Ktek5Xl.js → change_tracker-CWLh-wes.js} +3 -3
- package/schematics/bundles/{checker-DqUKCGda.js → checker-_f5wM7PH.js} +20 -3
- package/schematics/bundles/cleanup-unused-imports.js +25 -20
- package/schematics/bundles/{compiler-CuoiHqkc.js → compiler-BaCbbux6.js} +964 -298
- package/schematics/bundles/compiler_host-CAfDJO3W.js +1 -1
- package/schematics/bundles/control-flow-migration.js +2 -2
- package/schematics/bundles/document-core.js +12 -12
- package/schematics/bundles/imports-CIX-JgAN.js +1 -1
- package/schematics/bundles/{index-CwFQSYXZ.js → index--W6S49uu.js} +10 -10
- package/schematics/bundles/{index-WFXCe5Q0.js → index-rsJ8I_hu.js} +131 -64
- package/schematics/bundles/inject-flags.js +14 -14
- package/schematics/bundles/inject-migration.js +108 -19
- package/schematics/bundles/leading_space-D9nQ8UQC.js +1 -1
- package/schematics/bundles/{migrate_ts_type_references-BNuHufqZ.js → migrate_ts_type_references-C4D_SzJk.js} +21 -21
- package/schematics/bundles/ng_decorators-DznZ5jMl.js +1 -1
- package/schematics/bundles/nodes-B16H9JUd.js +1 -1
- package/schematics/bundles/output-migration.js +80 -22
- package/schematics/bundles/{run_in_devkit-CmHxABFr.js → project_paths-Ce0O2u-M.js} +254 -244
- package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.js +1 -1
- package/schematics/bundles/property_name-BBwFuqMe.js +1 -1
- package/schematics/bundles/route-lazy-loading.js +4 -4
- package/schematics/bundles/self-closing-tags-migration.js +20 -15
- package/schematics/bundles/signal-input-migration.js +26 -21
- package/schematics/bundles/signal-queries-migration.js +32 -27
- package/schematics/bundles/signals.js +8 -8
- package/schematics/bundles/standalone-migration.js +5 -5
- package/schematics/bundles/symbol-VPWguRxr.js +1 -1
- package/schematics/bundles/test-bed-get.js +13 -13
- package/{signal.d-BeaTIeOE.d.ts → signal.d-E0e5nW1p.d.ts} +4 -4
- package/testing/index.d.ts +9 -25
- package/{weak_ref.d-ttyj86RV.d.ts → weak_ref.d-eGOEP9S1.d.ts} +2 -2
- package/fesm2022/debug_node-xKpCIZm-.mjs.map +0 -1
- package/fesm2022/resource-BPpYEDic.mjs.map +0 -1
- package/fesm2022/root_effect_scheduler-D0_b1cf_.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
3
|
+
* @license Angular v20.0.0-next.7
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
var ts = require('typescript');
|
|
10
10
|
require('os');
|
|
11
|
-
var checker = require('./checker-
|
|
12
|
-
require('./compiler-
|
|
13
|
-
require('./index-
|
|
11
|
+
var checker = require('./checker-_f5wM7PH.js');
|
|
12
|
+
require('./compiler-BaCbbux6.js');
|
|
13
|
+
require('./index-rsJ8I_hu.js');
|
|
14
14
|
require('path');
|
|
15
|
-
var
|
|
16
|
-
var apply_import_manager = require('./apply_import_manager-
|
|
15
|
+
var project_paths = require('./project_paths-Ce0O2u-M.js');
|
|
16
|
+
var apply_import_manager = require('./apply_import_manager-DczRKpTm.js');
|
|
17
17
|
var imports = require('./imports-CIX-JgAN.js');
|
|
18
18
|
require('@angular-devkit/core');
|
|
19
19
|
require('node:path/posix');
|
|
@@ -32,7 +32,7 @@ const FLAGS_TO_FIELDS = {
|
|
|
32
32
|
'SkipSelf': 'skipSelf',
|
|
33
33
|
};
|
|
34
34
|
/** Migration that replaces `InjectFlags` usages with object literals. */
|
|
35
|
-
class InjectFlagsMigration extends
|
|
35
|
+
class InjectFlagsMigration extends project_paths.TsurgeFunnelMigration {
|
|
36
36
|
async analyze(info) {
|
|
37
37
|
const locations = {};
|
|
38
38
|
const importRemovals = {};
|
|
@@ -41,7 +41,7 @@ class InjectFlagsMigration extends run_in_devkit.TsurgeFunnelMigration {
|
|
|
41
41
|
if (specifier === null) {
|
|
42
42
|
continue;
|
|
43
43
|
}
|
|
44
|
-
const file =
|
|
44
|
+
const file = project_paths.projectFile(sourceFile, info);
|
|
45
45
|
const importManager = new checker.ImportManager();
|
|
46
46
|
const importReplacements = [];
|
|
47
47
|
// Always remove the `InjectFlags` since it has been removed from Angular.
|
|
@@ -73,7 +73,7 @@ class InjectFlagsMigration extends run_in_devkit.TsurgeFunnelMigration {
|
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
return
|
|
76
|
+
return project_paths.confirmAsSerializable({ locations, importRemovals });
|
|
77
77
|
}
|
|
78
78
|
async migrate(globalData) {
|
|
79
79
|
const replacements = [];
|
|
@@ -84,12 +84,12 @@ class InjectFlagsMigration extends run_in_devkit.TsurgeFunnelMigration {
|
|
|
84
84
|
// Declare a property for each flag, except for `default` which does not have a flag.
|
|
85
85
|
const properties = flags.filter((flag) => flag !== 'default').map((flag) => `${flag}: true`);
|
|
86
86
|
const toInsert = properties.length ? `{ ${properties.join(', ')} }` : '{}';
|
|
87
|
-
replacements.push(new
|
|
87
|
+
replacements.push(new project_paths.Replacement(file, new project_paths.TextUpdate({ position, end, toInsert })));
|
|
88
88
|
}
|
|
89
|
-
return
|
|
89
|
+
return project_paths.confirmAsSerializable({ replacements });
|
|
90
90
|
}
|
|
91
91
|
async combine(unitA, unitB) {
|
|
92
|
-
return
|
|
92
|
+
return project_paths.confirmAsSerializable({
|
|
93
93
|
locations: {
|
|
94
94
|
...unitA.locations,
|
|
95
95
|
...unitB.locations,
|
|
@@ -101,7 +101,7 @@ class InjectFlagsMigration extends run_in_devkit.TsurgeFunnelMigration {
|
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
async globalMeta(combinedData) {
|
|
104
|
-
return
|
|
104
|
+
return project_paths.confirmAsSerializable(combinedData);
|
|
105
105
|
}
|
|
106
106
|
async stats() {
|
|
107
107
|
return { counters: {} };
|
|
@@ -138,7 +138,7 @@ function getInjectFlagsRootExpression(start) {
|
|
|
138
138
|
|
|
139
139
|
function migrate() {
|
|
140
140
|
return async (tree) => {
|
|
141
|
-
await
|
|
141
|
+
await project_paths.runMigrationInDevkit({
|
|
142
142
|
tree,
|
|
143
143
|
getMigration: () => new InjectFlagsMigration(),
|
|
144
144
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
3
|
+
* @license Angular v20.0.0-next.7
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
var schematics = require('@angular-devkit/schematics');
|
|
10
10
|
var p = require('path');
|
|
11
|
-
var change_tracker = require('./change_tracker-
|
|
11
|
+
var change_tracker = require('./change_tracker-CWLh-wes.js');
|
|
12
12
|
var compiler_host = require('./compiler_host-CAfDJO3W.js');
|
|
13
13
|
var ts = require('typescript');
|
|
14
14
|
var ng_decorators = require('./ng_decorators-DznZ5jMl.js');
|
|
15
15
|
var imports = require('./imports-CIX-JgAN.js');
|
|
16
16
|
var nodes = require('./nodes-B16H9JUd.js');
|
|
17
17
|
var leading_space = require('./leading_space-D9nQ8UQC.js');
|
|
18
|
-
require('./compiler-
|
|
19
|
-
require('./checker-
|
|
18
|
+
require('./compiler-BaCbbux6.js');
|
|
19
|
+
require('./checker-_f5wM7PH.js');
|
|
20
20
|
require('os');
|
|
21
21
|
require('fs');
|
|
22
22
|
require('module');
|
|
@@ -373,7 +373,7 @@ function isInlineFunction(node) {
|
|
|
373
373
|
* @param constructor Constructor declaration of the class being migrated.
|
|
374
374
|
* @param localTypeChecker Type checker scoped to the current file.
|
|
375
375
|
*/
|
|
376
|
-
function findUninitializedPropertiesToCombine(node, constructor, localTypeChecker) {
|
|
376
|
+
function findUninitializedPropertiesToCombine(node, constructor, localTypeChecker, options) {
|
|
377
377
|
let toCombine = null;
|
|
378
378
|
let toHoist = [];
|
|
379
379
|
const membersToDeclarations = new Map();
|
|
@@ -391,10 +391,13 @@ function findUninitializedPropertiesToCombine(node, constructor, localTypeChecke
|
|
|
391
391
|
if (memberInitializers === null) {
|
|
392
392
|
return null;
|
|
393
393
|
}
|
|
394
|
+
const inlinableParameters = options._internalReplaceParameterReferencesInInitializers
|
|
395
|
+
? findInlinableParameterReferences(constructor, localTypeChecker)
|
|
396
|
+
: new Set();
|
|
394
397
|
for (const [name, decl] of membersToDeclarations.entries()) {
|
|
395
398
|
if (memberInitializers.has(name)) {
|
|
396
399
|
const initializer = memberInitializers.get(name);
|
|
397
|
-
if (!hasLocalReferences(initializer, constructor, localTypeChecker)) {
|
|
400
|
+
if (!hasLocalReferences(initializer, constructor, inlinableParameters, localTypeChecker)) {
|
|
398
401
|
toCombine ??= [];
|
|
399
402
|
toCombine.push({ declaration: membersToDeclarations.get(name), initializer });
|
|
400
403
|
}
|
|
@@ -536,13 +539,70 @@ function getMemberInitializers(constructor) {
|
|
|
536
539
|
}
|
|
537
540
|
return memberInitializers;
|
|
538
541
|
}
|
|
542
|
+
/**
|
|
543
|
+
* Checks if the node is an identifier that references a property from the given
|
|
544
|
+
* list. Returns the property if it is.
|
|
545
|
+
*/
|
|
546
|
+
function getIdentifierReferencingProperty(node, localTypeChecker, propertyNames, properties) {
|
|
547
|
+
if (!ts.isIdentifier(node) || !propertyNames.has(node.text)) {
|
|
548
|
+
return undefined;
|
|
549
|
+
}
|
|
550
|
+
const declarations = localTypeChecker.getSymbolAtLocation(node)?.declarations;
|
|
551
|
+
if (!declarations) {
|
|
552
|
+
return undefined;
|
|
553
|
+
}
|
|
554
|
+
for (const decl of declarations) {
|
|
555
|
+
if (properties.has(decl)) {
|
|
556
|
+
return decl;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return undefined;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Returns true if the node introduces a new `this` scope (so we can't
|
|
563
|
+
* reference the outer this).
|
|
564
|
+
*/
|
|
565
|
+
function introducesNewThisScope(node) {
|
|
566
|
+
return (ts.isFunctionDeclaration(node) ||
|
|
567
|
+
ts.isFunctionExpression(node) ||
|
|
568
|
+
ts.isMethodDeclaration(node) ||
|
|
569
|
+
ts.isClassDeclaration(node) ||
|
|
570
|
+
ts.isClassExpression(node));
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Finds constructor parameter references which can be inlined as `this.prop`.
|
|
574
|
+
* - prop must be a readonly property
|
|
575
|
+
* - the reference can't be in a nested function where `this` might refer
|
|
576
|
+
* to something else
|
|
577
|
+
*/
|
|
578
|
+
function findInlinableParameterReferences(constructorDeclaration, localTypeChecker) {
|
|
579
|
+
const eligibleProperties = constructorDeclaration.parameters.filter((p) => ts.isIdentifier(p.name) && p.modifiers?.some((s) => s.kind === ts.SyntaxKind.ReadonlyKeyword));
|
|
580
|
+
const eligibleNames = new Set(eligibleProperties.map((p) => p.name.text));
|
|
581
|
+
const eligiblePropertiesSet = new Set(eligibleProperties);
|
|
582
|
+
function walk(node, canReferenceThis) {
|
|
583
|
+
const property = getIdentifierReferencingProperty(node, localTypeChecker, eligibleNames, eligiblePropertiesSet);
|
|
584
|
+
if (property && !canReferenceThis) {
|
|
585
|
+
// The property is referenced in a nested context where
|
|
586
|
+
// we can't use `this`, so we can't inline it.
|
|
587
|
+
eligiblePropertiesSet.delete(property);
|
|
588
|
+
}
|
|
589
|
+
else if (introducesNewThisScope(node)) {
|
|
590
|
+
canReferenceThis = false;
|
|
591
|
+
}
|
|
592
|
+
ts.forEachChild(node, (child) => {
|
|
593
|
+
walk(child, canReferenceThis);
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
walk(constructorDeclaration, true);
|
|
597
|
+
return eligiblePropertiesSet;
|
|
598
|
+
}
|
|
539
599
|
/**
|
|
540
600
|
* Determines if a node has references to local symbols defined in the constructor.
|
|
541
601
|
* @param root Expression to check for local references.
|
|
542
602
|
* @param constructor Constructor within which the expression is used.
|
|
543
603
|
* @param localTypeChecker Type checker scoped to the current file.
|
|
544
604
|
*/
|
|
545
|
-
function hasLocalReferences(root, constructor, localTypeChecker) {
|
|
605
|
+
function hasLocalReferences(root, constructor, allowedParameters, localTypeChecker) {
|
|
546
606
|
const sourceFile = root.getSourceFile();
|
|
547
607
|
let hasLocalRefs = false;
|
|
548
608
|
const walk = (node) => {
|
|
@@ -564,7 +624,8 @@ function hasLocalReferences(root, constructor, localTypeChecker) {
|
|
|
564
624
|
// The source file check is a bit redundant since the type checker
|
|
565
625
|
// is local to the file, but it's inexpensive and it can prevent
|
|
566
626
|
// bugs in the future if we decide to use a full type checker.
|
|
567
|
-
|
|
627
|
+
!allowedParameters.has(decl) &&
|
|
628
|
+
decl.getSourceFile() === sourceFile &&
|
|
568
629
|
decl.getStart() >= constructor.getStart() &&
|
|
569
630
|
decl.getEnd() <= constructor.getEnd() &&
|
|
570
631
|
!isInsideInlineFunction(decl, constructor));
|
|
@@ -628,7 +689,7 @@ function migrateFile(sourceFile, options) {
|
|
|
628
689
|
const removedStatements = new Set();
|
|
629
690
|
const removedMembers = new Set();
|
|
630
691
|
if (options._internalCombineMemberInitializers) {
|
|
631
|
-
applyInternalOnlyChanges(node, constructor, localTypeChecker, tracker, printer, removedStatements, removedMembers, prependToClass, afterInjectCalls, memberIndentation);
|
|
692
|
+
applyInternalOnlyChanges(node, constructor, localTypeChecker, tracker, printer, removedStatements, removedMembers, prependToClass, afterInjectCalls, memberIndentation, options);
|
|
632
693
|
}
|
|
633
694
|
migrateClass(node, constructor, superCall, options, memberIndentation, prependToClass, afterInjectCalls, removedStatements, removedMembers, localTypeChecker, printer, tracker);
|
|
634
695
|
});
|
|
@@ -1099,8 +1160,8 @@ function getNextPreservedStatement(startNode, removedStatements) {
|
|
|
1099
1160
|
* @param afterInjectCalls Text that will be inserted after the newly-added `inject` calls.
|
|
1100
1161
|
* @param memberIndentation Indentation string of the class' members.
|
|
1101
1162
|
*/
|
|
1102
|
-
function applyInternalOnlyChanges(node, constructor, localTypeChecker, tracker, printer, removedStatements, removedMembers, prependToClass, afterInjectCalls, memberIndentation) {
|
|
1103
|
-
const result = findUninitializedPropertiesToCombine(node, constructor, localTypeChecker);
|
|
1163
|
+
function applyInternalOnlyChanges(node, constructor, localTypeChecker, tracker, printer, removedStatements, removedMembers, prependToClass, afterInjectCalls, memberIndentation, options) {
|
|
1164
|
+
const result = findUninitializedPropertiesToCombine(node, constructor, localTypeChecker, options);
|
|
1104
1165
|
if (result === null) {
|
|
1105
1166
|
return;
|
|
1106
1167
|
}
|
|
@@ -1113,21 +1174,25 @@ function applyInternalOnlyChanges(node, constructor, localTypeChecker, tracker,
|
|
|
1113
1174
|
}
|
|
1114
1175
|
result.toCombine.forEach(({ declaration, initializer }) => {
|
|
1115
1176
|
const initializerStatement = nodes.closestNode(initializer, ts.isStatement);
|
|
1177
|
+
// Strip comments if we are just going modify the node in-place.
|
|
1178
|
+
const modifiers = preserveInitOrder
|
|
1179
|
+
? declaration.modifiers
|
|
1180
|
+
: cloneModifiers(declaration.modifiers);
|
|
1181
|
+
const name = preserveInitOrder ? declaration.name : cloneName(declaration.name);
|
|
1182
|
+
const newProperty = ts.factory.createPropertyDeclaration(modifiers, name, declaration.questionToken, declaration.type, undefined);
|
|
1183
|
+
const propText = printer.printNode(ts.EmitHint.Unspecified, newProperty, declaration.getSourceFile());
|
|
1184
|
+
const initializerText = replaceParameterReferencesInInitializer(initializer, constructor, localTypeChecker);
|
|
1185
|
+
const withInitializer = `${propText.slice(0, -1)} = ${initializerText};`;
|
|
1116
1186
|
// If the initialization order is being preserved, we have to remove the original
|
|
1117
1187
|
// declaration and re-declare it. Otherwise we can do the replacement in-place.
|
|
1118
1188
|
if (preserveInitOrder) {
|
|
1119
|
-
// Preserve comment in the new property since we are removing the entire node.
|
|
1120
|
-
const newProperty = ts.factory.createPropertyDeclaration(declaration.modifiers, declaration.name, declaration.questionToken, declaration.type, initializer);
|
|
1121
1189
|
tracker.removeNode(declaration, true);
|
|
1122
1190
|
removedMembers.add(declaration);
|
|
1123
|
-
afterInjectCalls.push(memberIndentation +
|
|
1124
|
-
printer.printNode(ts.EmitHint.Unspecified, newProperty, declaration.getSourceFile()));
|
|
1191
|
+
afterInjectCalls.push(memberIndentation + withInitializer);
|
|
1125
1192
|
}
|
|
1126
1193
|
else {
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
const newProperty = ts.factory.createPropertyDeclaration(cloneModifiers(declaration.modifiers), cloneName(declaration.name), declaration.questionToken, declaration.type, initializer);
|
|
1130
|
-
tracker.replaceNode(declaration, newProperty);
|
|
1194
|
+
const sourceFile = declaration.getSourceFile();
|
|
1195
|
+
tracker.replaceText(sourceFile, declaration.getStart(), declaration.getWidth(), withInitializer);
|
|
1131
1196
|
}
|
|
1132
1197
|
// This should always be defined, but null check it just in case.
|
|
1133
1198
|
if (initializerStatement) {
|
|
@@ -1145,6 +1210,30 @@ function applyInternalOnlyChanges(node, constructor, localTypeChecker, tracker,
|
|
|
1145
1210
|
prependToClass.push('');
|
|
1146
1211
|
}
|
|
1147
1212
|
}
|
|
1213
|
+
function replaceParameterReferencesInInitializer(initializer, constructor, localTypeChecker) {
|
|
1214
|
+
// 1. Collect the locations of identifier nodes that reference constructor parameters.
|
|
1215
|
+
// 2. Add `this.` to those locations.
|
|
1216
|
+
const insertLocations = [0];
|
|
1217
|
+
function walk(node) {
|
|
1218
|
+
if (ts.isIdentifier(node) &&
|
|
1219
|
+
!(ts.isPropertyAccessExpression(node.parent) && node === node.parent.name) &&
|
|
1220
|
+
localTypeChecker
|
|
1221
|
+
.getSymbolAtLocation(node)
|
|
1222
|
+
?.declarations?.some((decl) => constructor.parameters.includes(decl))) {
|
|
1223
|
+
insertLocations.push(node.getStart() - initializer.getStart());
|
|
1224
|
+
}
|
|
1225
|
+
ts.forEachChild(node, walk);
|
|
1226
|
+
}
|
|
1227
|
+
walk(initializer);
|
|
1228
|
+
const initializerText = initializer.getText();
|
|
1229
|
+
insertLocations.push(initializerText.length);
|
|
1230
|
+
insertLocations.sort((a, b) => a - b);
|
|
1231
|
+
const result = [];
|
|
1232
|
+
for (let i = 0; i < insertLocations.length - 1; i++) {
|
|
1233
|
+
result.push(initializerText.slice(insertLocations[i], insertLocations[i + 1]));
|
|
1234
|
+
}
|
|
1235
|
+
return result.join('this.');
|
|
1236
|
+
}
|
|
1148
1237
|
|
|
1149
1238
|
function migrate(options) {
|
|
1150
1239
|
return async (tree) => {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
3
|
+
* @license Angular v20.0.0-next.7
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
require('./compiler-
|
|
9
|
+
require('./compiler-BaCbbux6.js');
|
|
10
10
|
var ts = require('typescript');
|
|
11
|
-
var checker = require('./checker-
|
|
11
|
+
var checker = require('./checker-_f5wM7PH.js');
|
|
12
12
|
require('os');
|
|
13
13
|
var assert = require('assert');
|
|
14
|
-
var index = require('./index
|
|
15
|
-
var
|
|
14
|
+
var index = require('./index--W6S49uu.js');
|
|
15
|
+
var project_paths = require('./project_paths-Ce0O2u-M.js');
|
|
16
16
|
var leading_space = require('./leading_space-D9nQ8UQC.js');
|
|
17
|
-
require('./index-
|
|
17
|
+
require('./index-rsJ8I_hu.js');
|
|
18
18
|
require('path');
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -913,7 +913,7 @@ function removeFromUnionIfPossible(union, filter) {
|
|
|
913
913
|
*/
|
|
914
914
|
function insertPrecedingLine(node, info, text) {
|
|
915
915
|
const leadingSpace = leading_space.getLeadingLineWhitespaceOfNode(node);
|
|
916
|
-
return new
|
|
916
|
+
return new project_paths.Replacement(project_paths.projectFile(node.getSourceFile(), info), new project_paths.TextUpdate({
|
|
917
917
|
position: node.getStart(),
|
|
918
918
|
end: node.getStart(),
|
|
919
919
|
toInsert: `${text}\n${leadingSpace}`,
|
|
@@ -1254,20 +1254,20 @@ function createNewBlockToInsertVariable(node, file, toInsert) {
|
|
|
1254
1254
|
const contentSpace = ' '.repeat(character + 2);
|
|
1255
1255
|
return [
|
|
1256
1256
|
// Delete leading whitespace of the concise body.
|
|
1257
|
-
new
|
|
1257
|
+
new project_paths.Replacement(file, new project_paths.TextUpdate({
|
|
1258
1258
|
position: node.body.getFullStart(),
|
|
1259
1259
|
end: node.body.getStart(),
|
|
1260
1260
|
toInsert: '',
|
|
1261
1261
|
})),
|
|
1262
1262
|
// Insert leading block braces, and `toInsert` content.
|
|
1263
1263
|
// Wrap the previous expression in a return now.
|
|
1264
|
-
new
|
|
1264
|
+
new project_paths.Replacement(file, new project_paths.TextUpdate({
|
|
1265
1265
|
position: node.body.getStart(),
|
|
1266
1266
|
end: node.body.getStart(),
|
|
1267
1267
|
toInsert: ` {\n${contentSpace}${toInsert}\n${contentSpace}return `,
|
|
1268
1268
|
})),
|
|
1269
1269
|
// Add trailing brace.
|
|
1270
|
-
new
|
|
1270
|
+
new project_paths.Replacement(file, new project_paths.TextUpdate({
|
|
1271
1271
|
position: node.body.getEnd(),
|
|
1272
1272
|
end: node.body.getEnd(),
|
|
1273
1273
|
toInsert: `;\n${blockSpace}}`,
|
|
@@ -1297,7 +1297,7 @@ function migrateBindingElementInputReference(tsReferencesInBindingElements, info
|
|
|
1297
1297
|
const bindingElement = reference.parent;
|
|
1298
1298
|
const bindingDecl = index.getBindingElementDeclaration(bindingElement);
|
|
1299
1299
|
const sourceFile = bindingElement.getSourceFile();
|
|
1300
|
-
const file =
|
|
1300
|
+
const file = project_paths.projectFile(sourceFile, info);
|
|
1301
1301
|
const inputFieldName = bindingElement.propertyName ?? bindingElement.name;
|
|
1302
1302
|
assert(!ts.isObjectBindingPattern(inputFieldName) && !ts.isArrayBindingPattern(inputFieldName), 'Property of binding element cannot be another pattern.');
|
|
1303
1303
|
const tmpName = nameGenerator.generate(reference.text, bindingElement);
|
|
@@ -1315,7 +1315,7 @@ function migrateBindingElementInputReference(tsReferencesInBindingElements, info
|
|
|
1315
1315
|
console.error(`Could not migrate reference ${reference.text} in ${file.rootRelativePath}`);
|
|
1316
1316
|
continue;
|
|
1317
1317
|
}
|
|
1318
|
-
replacements.push(new
|
|
1318
|
+
replacements.push(new project_paths.Replacement(file, new project_paths.TextUpdate({
|
|
1319
1319
|
position: bindingElement.getStart(),
|
|
1320
1320
|
end: bindingElement.getEnd(),
|
|
1321
1321
|
toInsert: printer.printNode(ts.EmitHint.Unspecified, newBindingToAccessInputField, sourceFile),
|
|
@@ -1340,7 +1340,7 @@ function insertTemporaryVariableForBindingElement(expansionDecl, file, toInsert)
|
|
|
1340
1340
|
const leadingSpace = ' '.repeat(leadingSpaceCount);
|
|
1341
1341
|
const statement = parent.parent;
|
|
1342
1342
|
return [
|
|
1343
|
-
new
|
|
1343
|
+
new project_paths.Replacement(file, new project_paths.TextUpdate({
|
|
1344
1344
|
position: statement.getEnd(),
|
|
1345
1345
|
end: statement.getEnd(),
|
|
1346
1346
|
toInsert: `\n${leadingSpace}${toInsert}`,
|
|
@@ -1358,7 +1358,7 @@ function insertTemporaryVariableForBindingElement(expansionDecl, file, toInsert)
|
|
|
1358
1358
|
const leadingSpaceCount = ts.getLineAndCharacterOfPosition(sf, spaceReferenceNode.getStart()).character + spaceOffset;
|
|
1359
1359
|
const leadingSpace = ' '.repeat(leadingSpaceCount);
|
|
1360
1360
|
return [
|
|
1361
|
-
new
|
|
1361
|
+
new project_paths.Replacement(file, new project_paths.TextUpdate({
|
|
1362
1362
|
position: bodyBlock.getStart() + 1,
|
|
1363
1363
|
end: bodyBlock.getStart() + 1,
|
|
1364
1364
|
toInsert: `\n${leadingSpace}${toInsert}`,
|
|
@@ -1759,7 +1759,7 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1759
1759
|
// Unwrap the signal directly.
|
|
1760
1760
|
if (recommendedNode === 'preserve') {
|
|
1761
1761
|
// Append `()` to unwrap the signal.
|
|
1762
|
-
replacements.push(new
|
|
1762
|
+
replacements.push(new project_paths.Replacement(project_paths.projectFile(sf, info), new project_paths.TextUpdate({
|
|
1763
1763
|
position: originalNode.getEnd(),
|
|
1764
1764
|
end: originalNode.getEnd(),
|
|
1765
1765
|
toInsert: '()',
|
|
@@ -1773,7 +1773,7 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1773
1773
|
const toInsert = idToSharedField.get(recommendedNode);
|
|
1774
1774
|
const replaceNode = index.traverseAccess(originalNode);
|
|
1775
1775
|
assert(toInsert, 'no shared variable yet available');
|
|
1776
|
-
replacements.push(new
|
|
1776
|
+
replacements.push(new project_paths.Replacement(project_paths.projectFile(sf, info), new project_paths.TextUpdate({
|
|
1777
1777
|
position: replaceNode.getStart(),
|
|
1778
1778
|
end: replaceNode.getEnd(),
|
|
1779
1779
|
toInsert,
|
|
@@ -1793,7 +1793,7 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1793
1793
|
parent = parent.parent;
|
|
1794
1794
|
}
|
|
1795
1795
|
const replaceNode = index.traverseAccess(originalNode);
|
|
1796
|
-
const filePath =
|
|
1796
|
+
const filePath = project_paths.projectFile(sf, info);
|
|
1797
1797
|
const initializer = `${replaceNode.getText()}()`;
|
|
1798
1798
|
const fieldName = nameGenerator.generate(originalNode.text, referenceNodeInBlock);
|
|
1799
1799
|
let sharedValueAccessExpr;
|
|
@@ -1815,13 +1815,13 @@ function migrateStandardTsReference(tsReferencesWithNarrowing, checker, info, re
|
|
|
1815
1815
|
}
|
|
1816
1816
|
else {
|
|
1817
1817
|
const leadingSpace = ts.getLineAndCharacterOfPosition(sf, referenceNodeInBlock.getStart());
|
|
1818
|
-
replacements.push(new
|
|
1818
|
+
replacements.push(new project_paths.Replacement(filePath, new project_paths.TextUpdate({
|
|
1819
1819
|
position: referenceNodeInBlock.getStart(),
|
|
1820
1820
|
end: referenceNodeInBlock.getStart(),
|
|
1821
1821
|
toInsert: `${temporaryVariableStr}\n${' '.repeat(leadingSpace.character)}`,
|
|
1822
1822
|
})));
|
|
1823
1823
|
}
|
|
1824
|
-
replacements.push(new
|
|
1824
|
+
replacements.push(new project_paths.Replacement(project_paths.projectFile(sf, info), new project_paths.TextUpdate({
|
|
1825
1825
|
position: replaceNode.getStart(),
|
|
1826
1826
|
end: replaceNode.getEnd(),
|
|
1827
1827
|
toInsert: sharedValueAccessExpr,
|
|
@@ -1930,12 +1930,12 @@ function migrateTypeScriptTypeReferences(host, references, importManager, info)
|
|
|
1930
1930
|
exportSymbolName: 'UnwrapSignalInputs',
|
|
1931
1931
|
requestedFile: sf,
|
|
1932
1932
|
});
|
|
1933
|
-
host.replacements.push(new
|
|
1933
|
+
host.replacements.push(new project_paths.Replacement(project_paths.projectFile(sf, info), new project_paths.TextUpdate({
|
|
1934
1934
|
position: firstArg.getStart(),
|
|
1935
1935
|
end: firstArg.getStart(),
|
|
1936
1936
|
toInsert: `${host.printer.printNode(ts.EmitHint.Unspecified, unwrapImportExpr, sf)}<`,
|
|
1937
1937
|
})));
|
|
1938
|
-
host.replacements.push(new
|
|
1938
|
+
host.replacements.push(new project_paths.Replacement(project_paths.projectFile(sf, info), new project_paths.TextUpdate({ position: firstArg.getEnd(), end: firstArg.getEnd(), toInsert: '>' })));
|
|
1939
1939
|
}
|
|
1940
1940
|
}
|
|
1941
1941
|
}
|