@angular/core 19.0.0-next.10 → 19.0.0-next.11
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 +13205 -11798
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +1 -1
- package/fesm2022/primitives/signals.mjs +8 -6
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +72 -4
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +4 -4
- package/index.d.ts +527 -51
- package/package.json +1 -1
- package/primitives/event-dispatch/index.d.ts +1 -1
- package/primitives/signals/index.d.ts +3 -1
- package/rxjs-interop/index.d.ts +32 -1
- package/schematics/bundles/{checker-77660732.js → checker-51c08a1b.js} +112 -97
- package/schematics/bundles/{compiler_host-81f430d9.js → compiler_host-d7f120f0.js} +2 -2
- package/schematics/bundles/control-flow-migration.js +3 -3
- package/schematics/bundles/explicit-standalone-flag.js +6 -4
- package/schematics/bundles/imports-4ac08251.js +1 -1
- package/schematics/bundles/{group_replacements-1f48eff7.js → index-f7b283e6.js} +247 -1649
- package/schematics/bundles/inject-migration.js +7 -6
- package/schematics/bundles/leading_space-d190b83b.js +1 -1
- package/schematics/bundles/migrate_ts_type_references-b2b55f62.js +1448 -0
- package/schematics/bundles/{nodes-0e7d45ca.js → ng_decorators-4579dec6.js} +1 -14
- package/schematics/bundles/nodes-a535b2be.js +27 -0
- package/schematics/bundles/output-migration.js +7295 -0
- package/schematics/bundles/pending-tasks.js +3 -3
- package/schematics/bundles/{program-1413936a.js → program-6e6520d8.js} +40 -18
- package/schematics/bundles/project_tsconfig_paths-e9ccccbf.js +1 -1
- package/schematics/bundles/provide-initializer.js +190 -0
- package/schematics/bundles/route-lazy-loading.js +3 -3
- package/schematics/bundles/signal-input-migration.js +73 -60
- package/schematics/bundles/signal-queries-migration.js +119 -90
- package/schematics/bundles/signals.js +54 -0
- package/schematics/bundles/standalone-migration.js +12 -11
- package/schematics/collection.json +11 -0
- package/schematics/migrations.json +7 -1
- package/schematics/ng-generate/output-migration/schema.json +19 -0
- package/schematics/ng-generate/signals/schema.json +65 -0
- package/testing/index.d.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.0.0-next.
|
|
3
|
+
* @license Angular v19.0.0-next.11
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -9,20 +9,21 @@
|
|
|
9
9
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10
10
|
|
|
11
11
|
var schematics = require('@angular-devkit/schematics');
|
|
12
|
-
var
|
|
12
|
+
var migrate_ts_type_references = require('./migrate_ts_type_references-b2b55f62.js');
|
|
13
13
|
var ts = require('typescript');
|
|
14
14
|
require('os');
|
|
15
|
-
var checker = require('./checker-
|
|
16
|
-
var program = require('./program-
|
|
15
|
+
var checker = require('./checker-51c08a1b.js');
|
|
16
|
+
var program = require('./program-6e6520d8.js');
|
|
17
17
|
require('path');
|
|
18
|
+
var index = require('./index-f7b283e6.js');
|
|
18
19
|
var assert = require('assert');
|
|
19
20
|
var project_tsconfig_paths = require('./project_tsconfig_paths-e9ccccbf.js');
|
|
20
21
|
require('./leading_space-d190b83b.js');
|
|
21
|
-
require('@angular-devkit/core');
|
|
22
|
-
require('node:path/posix');
|
|
23
22
|
require('fs');
|
|
24
23
|
require('module');
|
|
25
24
|
require('url');
|
|
25
|
+
require('@angular-devkit/core');
|
|
26
|
+
require('node:path/posix');
|
|
26
27
|
|
|
27
28
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
28
29
|
|
|
@@ -100,7 +101,7 @@ function getInputDescriptor(hostOrInfo, node) {
|
|
|
100
101
|
className = node.parent.name?.text ?? '<anonymous>';
|
|
101
102
|
}
|
|
102
103
|
const info = hostOrInfo instanceof MigrationHost ? hostOrInfo.programInfo : hostOrInfo;
|
|
103
|
-
const file =
|
|
104
|
+
const file = index.projectFile(node.getSourceFile(), info);
|
|
104
105
|
// Inputs may be detected in `.d.ts` files. Ensure that if the file IDs
|
|
105
106
|
// match regardless of extension. E.g. `/google3/blaze-out/bin/my_file.ts` should
|
|
106
107
|
// have the same ID as `/google3/my_file.ts`.
|
|
@@ -119,11 +120,11 @@ function attemptRetrieveInputFromSymbol(programInfo, memberSymbol, knownInputs)
|
|
|
119
120
|
// Even for declared classes from `.d.ts`, the value declaration
|
|
120
121
|
// should exist and point to the property declaration.
|
|
121
122
|
if (memberSymbol.valueDeclaration !== undefined &&
|
|
122
|
-
|
|
123
|
+
index.isInputContainerNode(memberSymbol.valueDeclaration)) {
|
|
123
124
|
const member = memberSymbol.valueDeclaration;
|
|
124
125
|
// If the member itself is an input that is being migrated, we
|
|
125
126
|
// do not need to check, as overriding would be fine then— like before.
|
|
126
|
-
const memberInputDescr =
|
|
127
|
+
const memberInputDescr = index.isInputContainerNode(member)
|
|
127
128
|
? getInputDescriptor(programInfo, member)
|
|
128
129
|
: null;
|
|
129
130
|
return memberInputDescr !== null ? (knownInputs.get(memberInputDescr) ?? null) : null;
|
|
@@ -177,7 +178,7 @@ class KnownInputs {
|
|
|
177
178
|
}
|
|
178
179
|
const directiveInfo = this._classToDirectiveInfo.get(data.node.parent);
|
|
179
180
|
const inputInfo = {
|
|
180
|
-
file:
|
|
181
|
+
file: index.projectFile(data.node.getSourceFile(), this.programInfo),
|
|
181
182
|
metadata: data.metadata,
|
|
182
183
|
descriptor: data.descriptor,
|
|
183
184
|
container: directiveInfo,
|
|
@@ -203,8 +204,8 @@ class KnownInputs {
|
|
|
203
204
|
const inputInfo = this.knownInputIds.get(input.key);
|
|
204
205
|
const existingIncompatibility = inputInfo.container.getInputMemberIncompatibility(input);
|
|
205
206
|
// Ensure an existing more significant incompatibility is not overridden.
|
|
206
|
-
if (existingIncompatibility !== null &&
|
|
207
|
-
incompatibility =
|
|
207
|
+
if (existingIncompatibility !== null && migrate_ts_type_references.isFieldIncompatibility(existingIncompatibility)) {
|
|
208
|
+
incompatibility = migrate_ts_type_references.pickFieldIncompatibility(existingIncompatibility, incompatibility);
|
|
208
209
|
}
|
|
209
210
|
this.knownInputIds
|
|
210
211
|
.get(input.key)
|
|
@@ -232,13 +233,13 @@ class KnownInputs {
|
|
|
232
233
|
captureUnknownDerivedField(field) {
|
|
233
234
|
this.markFieldIncompatible(field, {
|
|
234
235
|
context: null,
|
|
235
|
-
reason:
|
|
236
|
+
reason: migrate_ts_type_references.FieldIncompatibilityReason.OverriddenByDerivedClass,
|
|
236
237
|
});
|
|
237
238
|
}
|
|
238
239
|
captureUnknownParentField(field) {
|
|
239
240
|
this.markFieldIncompatible(field, {
|
|
240
241
|
context: null,
|
|
241
|
-
reason:
|
|
242
|
+
reason: migrate_ts_type_references.FieldIncompatibilityReason.TypeConflictWithBaseClass,
|
|
242
243
|
});
|
|
243
244
|
}
|
|
244
245
|
}
|
|
@@ -317,7 +318,7 @@ function extractDecoratorInput(node, host, reflector, metadataReader, evaluator,
|
|
|
317
318
|
* part of a `.d.ts` file.
|
|
318
319
|
*/
|
|
319
320
|
function extractDtsInput(node, metadataReader) {
|
|
320
|
-
if (!
|
|
321
|
+
if (!index.isInputContainerNode(node) ||
|
|
321
322
|
!ts__default["default"].isIdentifier(node.name) ||
|
|
322
323
|
!node.getSourceFile().isDeclarationFile) {
|
|
323
324
|
return null;
|
|
@@ -340,6 +341,8 @@ function extractDtsInput(node, metadataReader) {
|
|
|
340
341
|
...inputMapping,
|
|
341
342
|
inputDecorator: null,
|
|
342
343
|
inSourceFile: false,
|
|
344
|
+
// Inputs from `.d.ts` cannot have any field decorators applied.
|
|
345
|
+
fieldDecorators: [],
|
|
343
346
|
};
|
|
344
347
|
}
|
|
345
348
|
/**
|
|
@@ -347,7 +350,7 @@ function extractDtsInput(node, metadataReader) {
|
|
|
347
350
|
* directly defined inside a source file (`.ts`).
|
|
348
351
|
*/
|
|
349
352
|
function extractSourceCodeInput(node, host, reflector, evaluator, refEmitter) {
|
|
350
|
-
if (!
|
|
353
|
+
if (!index.isInputContainerNode(node) ||
|
|
351
354
|
!ts__default["default"].isIdentifier(node.name) ||
|
|
352
355
|
node.getSourceFile().isDeclarationFile) {
|
|
353
356
|
return null;
|
|
@@ -391,6 +394,7 @@ function extractSourceCodeInput(node, host, reflector, evaluator, refEmitter) {
|
|
|
391
394
|
inSourceFile: true,
|
|
392
395
|
transform: transformResult,
|
|
393
396
|
inputDecorator,
|
|
397
|
+
fieldDecorators: decorators,
|
|
394
398
|
};
|
|
395
399
|
}
|
|
396
400
|
/**
|
|
@@ -430,7 +434,7 @@ function prepareAndCheckForConversion(node, metadata, checker, options) {
|
|
|
430
434
|
if (ts__default["default"].isAccessor(node)) {
|
|
431
435
|
return {
|
|
432
436
|
context: node,
|
|
433
|
-
reason:
|
|
437
|
+
reason: migrate_ts_type_references.FieldIncompatibilityReason.Accessor,
|
|
434
438
|
};
|
|
435
439
|
}
|
|
436
440
|
assert__default["default"](metadata.inputDecorator !== null, 'Expected an input decorator for inputs that are being migrated.');
|
|
@@ -474,7 +478,7 @@ function prepareAndCheckForConversion(node, metadata, checker, options) {
|
|
|
474
478
|
if (typeToAdd === undefined) {
|
|
475
479
|
return {
|
|
476
480
|
context: node,
|
|
477
|
-
reason:
|
|
481
|
+
reason: migrate_ts_type_references.FieldIncompatibilityReason.SignalInput__QuestionMarkButNoGoodExplicitTypeExtractable,
|
|
478
482
|
};
|
|
479
483
|
}
|
|
480
484
|
if (!checker.isTypeAssignableTo(checker.getUndefinedType(), checker.getTypeFromTypeNode(typeToAdd))) {
|
|
@@ -515,7 +519,7 @@ function prepareAndCheckForConversion(node, metadata, checker, options) {
|
|
|
515
519
|
// the generated type might depend on imports that we cannot add here (nor want).
|
|
516
520
|
return {
|
|
517
521
|
context: node,
|
|
518
|
-
reason:
|
|
522
|
+
reason: migrate_ts_type_references.FieldIncompatibilityReason.SignalInput__RequiredButNoGoodExplicitTypeExtractable,
|
|
519
523
|
};
|
|
520
524
|
}
|
|
521
525
|
}
|
|
@@ -567,7 +571,7 @@ function pass1__IdentifySourceFileAndDeclarationInputs(sf, host, checker, reflec
|
|
|
567
571
|
const visitor = (node) => {
|
|
568
572
|
const decoratorInput = extractDecoratorInput(node, host, reflector, dtsMetadataReader, evaluator, refEmitter);
|
|
569
573
|
if (decoratorInput !== null) {
|
|
570
|
-
assert__default["default"](
|
|
574
|
+
assert__default["default"](index.isInputContainerNode(node), 'Expected input to be declared on accessor or property.');
|
|
571
575
|
const inputDescr = getInputDescriptor(host, node);
|
|
572
576
|
// track all inputs, even from declarations for reference resolution.
|
|
573
577
|
knownDecoratorInputs.register({ descriptor: inputDescr, metadata: decoratorInput, node });
|
|
@@ -575,7 +579,7 @@ function pass1__IdentifySourceFileAndDeclarationInputs(sf, host, checker, reflec
|
|
|
575
579
|
// these are then later migrated in the migration phase.
|
|
576
580
|
if (decoratorInput.inSourceFile && host.isSourceFileForCurrentMigration(sf)) {
|
|
577
581
|
const conversionPreparation = prepareAndCheckForConversion(node, decoratorInput, checker, host.compilerOptions);
|
|
578
|
-
if (
|
|
582
|
+
if (migrate_ts_type_references.isFieldIncompatibility(conversionPreparation)) {
|
|
579
583
|
knownDecoratorInputs.markFieldIncompatible(inputDescr, conversionPreparation);
|
|
580
584
|
result.sourceInputs.set(inputDescr, null);
|
|
581
585
|
}
|
|
@@ -614,8 +618,17 @@ function pass1__IdentifySourceFileAndDeclarationInputs(sf, host, checker, reflec
|
|
|
614
618
|
* In addition, spying onto an input may be problematic- so we skip migrating
|
|
615
619
|
* such.
|
|
616
620
|
*/
|
|
617
|
-
function pass3__checkIncompatiblePatterns(inheritanceGraph, checker, groupedTsAstVisitor, knownInputs) {
|
|
618
|
-
|
|
621
|
+
function pass3__checkIncompatiblePatterns(host, inheritanceGraph, checker$1, groupedTsAstVisitor, knownInputs) {
|
|
622
|
+
migrate_ts_type_references.checkIncompatiblePatterns(inheritanceGraph, checker$1, groupedTsAstVisitor, knownInputs, () => knownInputs.getAllInputContainingClasses());
|
|
623
|
+
for (const input of knownInputs.knownInputIds.values()) {
|
|
624
|
+
const hostBindingDecorators = checker.getAngularDecorators(input.metadata.fieldDecorators, ['HostBinding'], host.isMigratingCore);
|
|
625
|
+
if (hostBindingDecorators.length > 0) {
|
|
626
|
+
knownInputs.markFieldIncompatible(input.descriptor, {
|
|
627
|
+
context: hostBindingDecorators[0].node,
|
|
628
|
+
reason: migrate_ts_type_references.FieldIncompatibilityReason.SignalIncompatibleWithHostBinding,
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
}
|
|
619
632
|
}
|
|
620
633
|
|
|
621
634
|
/**
|
|
@@ -629,7 +642,7 @@ function pass3__checkIncompatiblePatterns(inheritanceGraph, checker, groupedTsAs
|
|
|
629
642
|
* such.
|
|
630
643
|
*/
|
|
631
644
|
function pass2_IdentifySourceFileReferences(programInfo, checker, reflector, resourceLoader, evaluator, templateTypeChecker, groupedTsAstVisitor, knownInputs, result, fieldNamesToConsiderForReferenceLookup) {
|
|
632
|
-
groupedTsAstVisitor.register(
|
|
645
|
+
groupedTsAstVisitor.register(index.createFindAllSourceFileReferencesVisitor(programInfo, checker, reflector, resourceLoader, evaluator, templateTypeChecker, knownInputs, fieldNamesToConsiderForReferenceLookup, result).visitor);
|
|
633
646
|
}
|
|
634
647
|
|
|
635
648
|
/**
|
|
@@ -657,26 +670,26 @@ function executeAnalysisPhase(host, knownInputs, result, { sourceFiles, fullProg
|
|
|
657
670
|
}
|
|
658
671
|
// A graph starting with source files is sufficient. We will resolve into
|
|
659
672
|
// declaration files if a source file depends on such.
|
|
660
|
-
const inheritanceGraph = new
|
|
661
|
-
const pass2And3SourceFileVisitor = new
|
|
673
|
+
const inheritanceGraph = new migrate_ts_type_references.InheritanceGraph(typeChecker).expensivePopulate(sourceFiles);
|
|
674
|
+
const pass2And3SourceFileVisitor = new migrate_ts_type_references.GroupedTsAstVisitor(sourceFiles);
|
|
662
675
|
// Register pass 2. Find all source file references.
|
|
663
676
|
pass2_IdentifySourceFileReferences(host.programInfo, typeChecker, reflector, resourceLoader, evaluator, templateTypeChecker, pass2And3SourceFileVisitor, knownInputs, result, fieldNamesToConsiderForReferenceLookup);
|
|
664
677
|
// Register pass 3. Check incompatible patterns pass.
|
|
665
|
-
pass3__checkIncompatiblePatterns(inheritanceGraph, typeChecker, pass2And3SourceFileVisitor, knownInputs);
|
|
678
|
+
pass3__checkIncompatiblePatterns(host, inheritanceGraph, typeChecker, pass2And3SourceFileVisitor, knownInputs);
|
|
666
679
|
// Perform Pass 2 and Pass 3, efficiently in one pass.
|
|
667
680
|
pass2And3SourceFileVisitor.execute();
|
|
668
681
|
// Determine incompatible inputs based on resolved references.
|
|
669
682
|
for (const reference of result.references) {
|
|
670
|
-
if (
|
|
683
|
+
if (index.isTsReference(reference) && reference.from.isWrite) {
|
|
671
684
|
knownInputs.markFieldIncompatible(reference.target, {
|
|
672
|
-
reason:
|
|
685
|
+
reason: migrate_ts_type_references.FieldIncompatibilityReason.WriteAssignment,
|
|
673
686
|
context: reference.from.node,
|
|
674
687
|
});
|
|
675
688
|
}
|
|
676
|
-
if (
|
|
689
|
+
if (index.isTemplateReference(reference) || index.isHostBindingReference(reference)) {
|
|
677
690
|
if (reference.from.isWrite) {
|
|
678
691
|
knownInputs.markFieldIncompatible(reference.target, {
|
|
679
|
-
reason:
|
|
692
|
+
reason: migrate_ts_type_references.FieldIncompatibilityReason.WriteAssignment,
|
|
680
693
|
// No TS node context available for template or host bindings.
|
|
681
694
|
context: null,
|
|
682
695
|
});
|
|
@@ -684,10 +697,10 @@ function executeAnalysisPhase(host, knownInputs, result, { sourceFiles, fullProg
|
|
|
684
697
|
}
|
|
685
698
|
// TODO: Remove this when we support signal narrowing in templates.
|
|
686
699
|
// https://github.com/angular/angular/pull/55456.
|
|
687
|
-
if (
|
|
700
|
+
if (index.isTemplateReference(reference)) {
|
|
688
701
|
if (reference.from.isLikelyPartOfNarrowing) {
|
|
689
702
|
knownInputs.markFieldIncompatible(reference.target, {
|
|
690
|
-
reason:
|
|
703
|
+
reason: migrate_ts_type_references.FieldIncompatibilityReason.PotentiallyNarrowedInTemplateButNoSupportYet,
|
|
691
704
|
context: null,
|
|
692
705
|
});
|
|
693
706
|
}
|
|
@@ -717,7 +730,7 @@ function executeAnalysisPhase(host, knownInputs, result, { sourceFiles, fullProg
|
|
|
717
730
|
* would then have other derived classes as well, it would propagate the status.
|
|
718
731
|
*/
|
|
719
732
|
function pass4__checkInheritanceOfInputs(inheritanceGraph, metaRegistry, knownInputs) {
|
|
720
|
-
|
|
733
|
+
migrate_ts_type_references.checkInheritanceOfKnownFields(inheritanceGraph, metaRegistry, knownInputs, {
|
|
721
734
|
isClassWithKnownFields: (clazz) => knownInputs.isInputContainingClass(clazz),
|
|
722
735
|
getFieldsForClass: (clazz) => {
|
|
723
736
|
const directiveInfo = knownInputs.getDirectiveInfoForClass(clazz);
|
|
@@ -829,7 +842,7 @@ function mergeCompilationUnitData(metadataFiles) {
|
|
|
829
842
|
else {
|
|
830
843
|
// Input might not be incompatible in one target, but others might invalidate it.
|
|
831
844
|
// merge the incompatibility state.
|
|
832
|
-
existing.memberIncompatibility =
|
|
845
|
+
existing.memberIncompatibility = migrate_ts_type_references.pickFieldIncompatibility({ reason: info.memberIncompatibility, context: null }, { reason: existing.memberIncompatibility, context: null }).reason;
|
|
833
846
|
}
|
|
834
847
|
}
|
|
835
848
|
// Merge incompatibility of the class owning the input.
|
|
@@ -861,7 +874,7 @@ function mergeCompilationUnitData(metadataFiles) {
|
|
|
861
874
|
// If parent is incompatible and not migrated, then this input
|
|
862
875
|
// cannot be migrated either. Try propagating parent incompatibility then.
|
|
863
876
|
if (isNodeIncompatible(parent.data)) {
|
|
864
|
-
node.data.info.memberIncompatibility =
|
|
877
|
+
node.data.info.memberIncompatibility = migrate_ts_type_references.pickFieldIncompatibility({ reason: migrate_ts_type_references.FieldIncompatibilityReason.ParentIsIncompatible, context: null }, existingMemberIncompatibility).reason;
|
|
865
878
|
break;
|
|
866
879
|
}
|
|
867
880
|
}
|
|
@@ -873,7 +886,7 @@ function mergeCompilationUnitData(metadataFiles) {
|
|
|
873
886
|
const existingMemberIncompatibility = info.memberIncompatibility !== null
|
|
874
887
|
? { reason: info.memberIncompatibility, context: null }
|
|
875
888
|
: null;
|
|
876
|
-
info.memberIncompatibility =
|
|
889
|
+
info.memberIncompatibility = migrate_ts_type_references.pickFieldIncompatibility({ reason: migrate_ts_type_references.FieldIncompatibilityReason.OutsideOfMigrationScope, context: null }, existingMemberIncompatibility).reason;
|
|
877
890
|
}
|
|
878
891
|
}
|
|
879
892
|
return result;
|
|
@@ -941,7 +954,7 @@ function convertToSignalInput(node, { resolvedMetadata: metadata, resolvedType,
|
|
|
941
954
|
// When using the `input()` shorthand, try cutting of `undefined` from potential
|
|
942
955
|
// union types. `undefined` will be automatically included in the type.
|
|
943
956
|
if (ts__default["default"].isUnionTypeNode(resolvedType)) {
|
|
944
|
-
resolvedType =
|
|
957
|
+
resolvedType = migrate_ts_type_references.removeFromUnionIfPossible(resolvedType, (t) => t.kind !== ts__default["default"].SyntaxKind.UndefinedKeyword);
|
|
945
958
|
}
|
|
946
959
|
}
|
|
947
960
|
}
|
|
@@ -981,9 +994,9 @@ function convertToSignalInput(node, { resolvedMetadata: metadata, resolvedType,
|
|
|
981
994
|
const newPropertyText = result.printer.printNode(ts__default["default"].EmitHint.Unspecified, newNode, node.getSourceFile());
|
|
982
995
|
const replacements = [];
|
|
983
996
|
if (leadingTodoText !== null) {
|
|
984
|
-
replacements.push(
|
|
997
|
+
replacements.push(migrate_ts_type_references.insertPrecedingLine(node, info, '// TODO: Notes from signal input migration:'), ...migrate_ts_type_references.cutStringToLineLimit(leadingTodoText, 70).map((line) => migrate_ts_type_references.insertPrecedingLine(node, info, `// ${line}`)));
|
|
985
998
|
}
|
|
986
|
-
replacements.push(new
|
|
999
|
+
replacements.push(new index.Replacement(index.projectFile(node.getSourceFile(), info), new index.TextUpdate({
|
|
987
1000
|
position: node.getStart(),
|
|
988
1001
|
end: node.getEnd(),
|
|
989
1002
|
toInsert: newPropertyText,
|
|
@@ -1037,7 +1050,7 @@ function pass6__migrateInputDeclarations(host, checker, result, knownInputs, imp
|
|
|
1037
1050
|
const incompatibilityReason = inputInfo.container.getInputMemberIncompatibility(input);
|
|
1038
1051
|
// Add a TODO for the incompatible input, if desired.
|
|
1039
1052
|
if (incompatibilityReason !== null && host.config.insertTodosForSkippedFields) {
|
|
1040
|
-
result.replacements.push(...
|
|
1053
|
+
result.replacements.push(...migrate_ts_type_references.insertTodoForIncompatibility(input.node, info, incompatibilityReason, {
|
|
1041
1054
|
single: 'input',
|
|
1042
1055
|
plural: 'inputs',
|
|
1043
1056
|
}));
|
|
@@ -1063,7 +1076,7 @@ function pass6__migrateInputDeclarations(host, checker, result, knownInputs, imp
|
|
|
1063
1076
|
* previous migrate phases.
|
|
1064
1077
|
*/
|
|
1065
1078
|
function pass10_applyImportManager(importManager, result, sourceFiles, info) {
|
|
1066
|
-
|
|
1079
|
+
index.applyImportManagerChanges(importManager, result.replacements, sourceFiles, info);
|
|
1067
1080
|
}
|
|
1068
1081
|
|
|
1069
1082
|
/**
|
|
@@ -1073,7 +1086,7 @@ function pass10_applyImportManager(importManager, result, sourceFiles, info) {
|
|
|
1073
1086
|
* where needed to ensure narrowing continues to work. E.g.
|
|
1074
1087
|
*/
|
|
1075
1088
|
function pass5__migrateTypeScriptReferences(host, references, checker, info) {
|
|
1076
|
-
|
|
1089
|
+
migrate_ts_type_references.migrateTypeScriptReferences(host, references, checker, info);
|
|
1077
1090
|
}
|
|
1078
1091
|
|
|
1079
1092
|
/**
|
|
@@ -1084,7 +1097,7 @@ function pass7__migrateTemplateReferences(host, references) {
|
|
|
1084
1097
|
const seenFileReferences = new Set();
|
|
1085
1098
|
for (const reference of references) {
|
|
1086
1099
|
// This pass only deals with HTML template references.
|
|
1087
|
-
if (!
|
|
1100
|
+
if (!index.isTemplateReference(reference)) {
|
|
1088
1101
|
continue;
|
|
1089
1102
|
}
|
|
1090
1103
|
// Skip references to incompatible inputs.
|
|
@@ -1101,7 +1114,7 @@ function pass7__migrateTemplateReferences(host, references) {
|
|
|
1101
1114
|
const appendText = reference.from.isObjectShorthandExpression
|
|
1102
1115
|
? `: ${reference.from.read.name}()`
|
|
1103
1116
|
: `()`;
|
|
1104
|
-
host.replacements.push(new
|
|
1117
|
+
host.replacements.push(new index.Replacement(reference.from.templateFile, new index.TextUpdate({
|
|
1105
1118
|
position: reference.from.read.sourceSpan.end,
|
|
1106
1119
|
end: reference.from.read.sourceSpan.end,
|
|
1107
1120
|
toInsert: appendText,
|
|
@@ -1117,7 +1130,7 @@ function pass8__migrateHostBindings(host, references, info) {
|
|
|
1117
1130
|
const seenReferences = new WeakMap();
|
|
1118
1131
|
for (const reference of references) {
|
|
1119
1132
|
// This pass only deals with host binding references.
|
|
1120
|
-
if (!
|
|
1133
|
+
if (!index.isHostBindingReference(reference)) {
|
|
1121
1134
|
continue;
|
|
1122
1135
|
}
|
|
1123
1136
|
// Skip references to incompatible inputs.
|
|
@@ -1141,7 +1154,7 @@ function pass8__migrateHostBindings(host, references, info) {
|
|
|
1141
1154
|
const appendText = reference.from.isObjectShorthandExpression
|
|
1142
1155
|
? `: ${reference.from.read.name}()`
|
|
1143
1156
|
: `()`;
|
|
1144
|
-
host.replacements.push(new
|
|
1157
|
+
host.replacements.push(new index.Replacement(index.projectFile(bindingField.getSourceFile(), info), new index.TextUpdate({ position: readEndPos, end: readEndPos, toInsert: appendText })));
|
|
1145
1158
|
}
|
|
1146
1159
|
}
|
|
1147
1160
|
|
|
@@ -1152,7 +1165,7 @@ function pass8__migrateHostBindings(host, references, info) {
|
|
|
1152
1165
|
in Catalyst test files.
|
|
1153
1166
|
*/
|
|
1154
1167
|
function pass9__migrateTypeScriptTypeReferences(host, references, importManager, info) {
|
|
1155
|
-
|
|
1168
|
+
migrate_ts_type_references.migrateTypeScriptTypeReferences(host, references, importManager, info);
|
|
1156
1169
|
}
|
|
1157
1170
|
|
|
1158
1171
|
/**
|
|
@@ -1193,7 +1206,7 @@ function filterIncompatibilitiesForBestEffortMode(knownInputs) {
|
|
|
1193
1206
|
// All class incompatibilities are "filterable" right now.
|
|
1194
1207
|
c.incompatible = null;
|
|
1195
1208
|
for (const [key, i] of c.memberIncompatibility.entries()) {
|
|
1196
|
-
if (!
|
|
1209
|
+
if (!migrate_ts_type_references.nonIgnorableFieldIncompatibilities.includes(i.reason)) {
|
|
1197
1210
|
c.memberIncompatibility.delete(key);
|
|
1198
1211
|
}
|
|
1199
1212
|
}
|
|
@@ -1204,7 +1217,7 @@ function filterIncompatibilitiesForBestEffortMode(knownInputs) {
|
|
|
1204
1217
|
* Tsurge migration for migrating Angular `@Input()` declarations to
|
|
1205
1218
|
* signal inputs, with support for batch execution.
|
|
1206
1219
|
*/
|
|
1207
|
-
class SignalInputMigration extends
|
|
1220
|
+
class SignalInputMigration extends index.TsurgeComplexMigration {
|
|
1208
1221
|
constructor(config = {}) {
|
|
1209
1222
|
super();
|
|
1210
1223
|
this.config = config;
|
|
@@ -1212,7 +1225,7 @@ class SignalInputMigration extends group_replacements.TsurgeComplexMigration {
|
|
|
1212
1225
|
}
|
|
1213
1226
|
// Override the default ngtsc program creation, to add extra flags.
|
|
1214
1227
|
createProgram(tsconfigAbsPath, fs) {
|
|
1215
|
-
return
|
|
1228
|
+
return index.createNgtscProgram(tsconfigAbsPath, fs, {
|
|
1216
1229
|
_compilePoisonedComponents: true,
|
|
1217
1230
|
// We want to migrate non-exported classes too.
|
|
1218
1231
|
compileNonExportedClasses: true,
|
|
@@ -1285,10 +1298,10 @@ class SignalInputMigration extends group_replacements.TsurgeComplexMigration {
|
|
|
1285
1298
|
knownInputs,
|
|
1286
1299
|
};
|
|
1287
1300
|
}
|
|
1288
|
-
return
|
|
1301
|
+
return index.confirmAsSerializable(unitData);
|
|
1289
1302
|
}
|
|
1290
1303
|
async merge(units) {
|
|
1291
|
-
return
|
|
1304
|
+
return index.confirmAsSerializable(mergeCompilationUnitData(units));
|
|
1292
1305
|
}
|
|
1293
1306
|
async migrate(globalMetadata, info, nonBatchData) {
|
|
1294
1307
|
const knownInputs = nonBatchData?.knownInputs ?? new KnownInputs(info, this.config);
|
|
@@ -1317,8 +1330,8 @@ class SignalInputMigration extends group_replacements.TsurgeComplexMigration {
|
|
|
1317
1330
|
for (const [id, input] of Object.entries(globalMetadata.knownInputs)) {
|
|
1318
1331
|
fullCompilationInputs++;
|
|
1319
1332
|
const isConsideredSourceInput = input.seenAsSourceInput &&
|
|
1320
|
-
input.memberIncompatibility !==
|
|
1321
|
-
input.memberIncompatibility !==
|
|
1333
|
+
input.memberIncompatibility !== migrate_ts_type_references.FieldIncompatibilityReason.OutsideOfMigrationScope &&
|
|
1334
|
+
input.memberIncompatibility !== migrate_ts_type_references.FieldIncompatibilityReason.SkippedViaConfigFilter;
|
|
1322
1335
|
// We won't track incompatibilities to inputs that aren't considered source inputs.
|
|
1323
1336
|
// Tracking their statistics wouldn't provide any value.
|
|
1324
1337
|
if (!isConsideredSourceInput) {
|
|
@@ -1329,13 +1342,13 @@ class SignalInputMigration extends group_replacements.TsurgeComplexMigration {
|
|
|
1329
1342
|
incompatibleInputs++;
|
|
1330
1343
|
}
|
|
1331
1344
|
if (input.memberIncompatibility !== null) {
|
|
1332
|
-
const reasonName =
|
|
1345
|
+
const reasonName = migrate_ts_type_references.FieldIncompatibilityReason[input.memberIncompatibility];
|
|
1333
1346
|
const key = `input-field-incompatibility-${reasonName}`;
|
|
1334
1347
|
fieldIncompatibleCounts[key] ??= 0;
|
|
1335
1348
|
fieldIncompatibleCounts[key]++;
|
|
1336
1349
|
}
|
|
1337
1350
|
if (input.owningClassIncompatibility !== null) {
|
|
1338
|
-
const reasonName =
|
|
1351
|
+
const reasonName = migrate_ts_type_references.ClassIncompatibilityReason[input.owningClassIncompatibility];
|
|
1339
1352
|
const key = `input-owning-class-incompatibility-${reasonName}`;
|
|
1340
1353
|
classIncompatibleCounts[key] ??= 0;
|
|
1341
1354
|
classIncompatibleCounts[key]++;
|
|
@@ -1367,7 +1380,7 @@ function filterInputsViaConfig(result, knownInputs, config) {
|
|
|
1367
1380
|
skippedInputs.add(input.descriptor.key);
|
|
1368
1381
|
knownInputs.markFieldIncompatible(input.descriptor, {
|
|
1369
1382
|
context: null,
|
|
1370
|
-
reason:
|
|
1383
|
+
reason: migrate_ts_type_references.FieldIncompatibilityReason.SkippedViaConfigFilter,
|
|
1371
1384
|
});
|
|
1372
1385
|
}
|
|
1373
1386
|
}
|
|
@@ -1382,7 +1395,7 @@ function migrate(options) {
|
|
|
1382
1395
|
if (!buildPaths.length && !testPaths.length) {
|
|
1383
1396
|
throw new schematics.SchematicsException('Could not find any tsconfig file. Cannot run signal input migration.');
|
|
1384
1397
|
}
|
|
1385
|
-
const fs = new
|
|
1398
|
+
const fs = new index.DevkitMigrationFilesystem(tree);
|
|
1386
1399
|
checker.setFileSystem(fs);
|
|
1387
1400
|
const migration = new SignalInputMigration({
|
|
1388
1401
|
bestEffortMode: options.bestEffortMode,
|
|
@@ -1419,7 +1432,7 @@ function migrate(options) {
|
|
|
1419
1432
|
for (const { info, tsconfigPath } of programInfos) {
|
|
1420
1433
|
context.logger.info(`Migrating: ${tsconfigPath}..`);
|
|
1421
1434
|
const { replacements } = await migration.migrate(merged, info);
|
|
1422
|
-
const changesPerFile =
|
|
1435
|
+
const changesPerFile = index.groupReplacementsByFile(replacements);
|
|
1423
1436
|
for (const [file, changes] of changesPerFile) {
|
|
1424
1437
|
if (!replacementsPerFile.has(file)) {
|
|
1425
1438
|
replacementsPerFile.set(file, changes);
|