@angular/core 20.0.0-next.0 → 20.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/core.mjs +3307 -4479
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/di.mjs +45 -0
- package/fesm2022/primitives/di.mjs.map +1 -0
- package/fesm2022/primitives/event-dispatch.mjs +3 -590
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +19 -9
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +8 -33
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +392 -250
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/weak_ref-DrMdAIDh.mjs +12 -0
- package/fesm2022/weak_ref-DrMdAIDh.mjs.map +1 -0
- package/index.d.ts +14339 -15134
- package/navigation_types.d-u4EOrrdZ.d.ts +121 -0
- package/package.json +11 -1
- package/primitives/di/index.d.ts +91 -0
- package/primitives/event-dispatch/index.d.ts +206 -310
- package/primitives/signals/index.d.ts +159 -196
- package/rxjs-interop/index.d.ts +72 -92
- package/schematics/bundles/{apply_import_manager-0959b78c.js → apply_import_manager-CyRT0UvU.js} +13 -17
- package/schematics/bundles/{checker-cf6f7980.js → checker-DF8ZaFW5.js} +3363 -1289
- package/schematics/bundles/cleanup-unused-imports.js +22 -28
- package/schematics/bundles/{compiler_host-cc1379e9.js → compiler_host-Da636uJ8.js} +20 -24
- package/schematics/bundles/control-flow-migration.js +82 -39
- package/schematics/bundles/{imports-31a38653.js → imports-CIX-JgAN.js} +10 -15
- package/schematics/bundles/{index-42d84d69.js → index-DnkWgagp.js} +56 -60
- package/schematics/bundles/{index-6675d6bc.js → index-vGJcp5M7.js} +5 -5
- package/schematics/bundles/inject-flags.js +181 -0
- package/schematics/bundles/inject-migration.js +122 -128
- package/schematics/bundles/{leading_space-6e7a8ec6.js → leading_space-D9nQ8UQC.js} +2 -2
- package/schematics/bundles/{migrate_ts_type_references-5089e4ef.js → migrate_ts_type_references-DtkOnnv0.js} +113 -120
- package/schematics/bundles/{ng_decorators-6878e227.js → ng_decorators-DznZ5jMl.js} +5 -9
- package/schematics/bundles/{nodes-ffdce442.js → nodes-B16H9JUd.js} +3 -7
- package/schematics/bundles/output-migration.js +40 -46
- package/schematics/bundles/{program-362689f0.js → program-BZk27Ndu.js} +846 -2653
- package/schematics/bundles/{project_paths-7d2daa1e.js → project_paths-Jtbi76Bs.js} +26 -24
- package/schematics/bundles/{project_tsconfig_paths-6c9cde78.js → project_tsconfig_paths-CDVxT6Ov.js} +2 -2
- package/schematics/bundles/{property_name-42030525.js → property_name-BBwFuqMe.js} +4 -8
- package/schematics/bundles/route-lazy-loading.js +36 -42
- package/schematics/bundles/self-closing-tags-migration.js +55 -45
- package/schematics/bundles/signal-input-migration.js +61 -68
- package/schematics/bundles/signal-queries-migration.js +48 -55
- package/schematics/bundles/signals.js +10 -12
- package/schematics/bundles/standalone-migration.js +179 -185
- package/schematics/migrations.json +4 -15
- package/testing/index.d.ts +309 -478
- package/weak_ref.d-ttyj86RV.d.ts +9 -0
- package/schematics/bundles/explicit-standalone-flag.js +0 -184
- package/schematics/bundles/pending-tasks.js +0 -103
- package/schematics/bundles/provide-initializer.js +0 -186
|
@@ -1,37 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
4
|
-
* (c) 2010-
|
|
3
|
+
* @license Angular v20.0.0-next.2
|
|
4
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10
|
-
|
|
11
9
|
var schematics = require('@angular-devkit/schematics');
|
|
12
|
-
var migrate_ts_type_references = require('./migrate_ts_type_references-
|
|
10
|
+
var migrate_ts_type_references = require('./migrate_ts_type_references-DtkOnnv0.js');
|
|
13
11
|
var ts = require('typescript');
|
|
14
12
|
require('os');
|
|
15
|
-
var checker = require('./checker-
|
|
16
|
-
var program = require('./program-
|
|
13
|
+
var checker = require('./checker-DF8ZaFW5.js');
|
|
14
|
+
var program = require('./program-BZk27Ndu.js');
|
|
17
15
|
require('path');
|
|
18
|
-
var project_paths = require('./project_paths-
|
|
19
|
-
var index = require('./index-
|
|
16
|
+
var project_paths = require('./project_paths-Jtbi76Bs.js');
|
|
17
|
+
var index = require('./index-DnkWgagp.js');
|
|
20
18
|
var assert = require('assert');
|
|
21
|
-
var apply_import_manager = require('./apply_import_manager-
|
|
22
|
-
var project_tsconfig_paths = require('./project_tsconfig_paths-
|
|
23
|
-
require('./leading_space-
|
|
19
|
+
var apply_import_manager = require('./apply_import_manager-CyRT0UvU.js');
|
|
20
|
+
var project_tsconfig_paths = require('./project_tsconfig_paths-CDVxT6Ov.js');
|
|
21
|
+
require('./leading_space-D9nQ8UQC.js');
|
|
24
22
|
require('fs');
|
|
25
23
|
require('module');
|
|
26
24
|
require('url');
|
|
27
25
|
require('@angular-devkit/core');
|
|
28
26
|
require('node:path/posix');
|
|
29
27
|
|
|
30
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
31
|
-
|
|
32
|
-
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
33
|
-
var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
|
|
34
|
-
|
|
35
28
|
/**
|
|
36
29
|
* Class that holds information about a given directive and its input fields.
|
|
37
30
|
*/
|
|
@@ -102,7 +95,7 @@ class MigrationHost {
|
|
|
102
95
|
|
|
103
96
|
function getInputDescriptor(hostOrInfo, node) {
|
|
104
97
|
let className;
|
|
105
|
-
if (
|
|
98
|
+
if (ts.isAccessor(node)) {
|
|
106
99
|
className = node.parent.name?.text || '<anonymous>';
|
|
107
100
|
}
|
|
108
101
|
else {
|
|
@@ -307,7 +300,7 @@ function prepareAnalysisInfo(userProgram, compiler, programAbsoluteRootPaths) {
|
|
|
307
300
|
* - imports that may need to be updated.
|
|
308
301
|
*/
|
|
309
302
|
class MigrationResult {
|
|
310
|
-
printer =
|
|
303
|
+
printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
|
|
311
304
|
// May be `null` if the input cannot be converted. This is also
|
|
312
305
|
// signified by an incompatibility- but the input is tracked here as it
|
|
313
306
|
// still is a "source input".
|
|
@@ -329,14 +322,14 @@ function extractDecoratorInput(node, host, reflector, metadataReader, evaluator)
|
|
|
329
322
|
*/
|
|
330
323
|
function extractDtsInput(node, metadataReader) {
|
|
331
324
|
if (!index.isInputContainerNode(node) ||
|
|
332
|
-
!
|
|
325
|
+
!ts.isIdentifier(node.name) ||
|
|
333
326
|
!node.getSourceFile().isDeclarationFile) {
|
|
334
327
|
return null;
|
|
335
328
|
}
|
|
336
329
|
// If the potential node is not part of a valid input class, skip.
|
|
337
|
-
if (!
|
|
330
|
+
if (!ts.isClassDeclaration(node.parent) ||
|
|
338
331
|
node.parent.name === undefined ||
|
|
339
|
-
!
|
|
332
|
+
!ts.isIdentifier(node.parent.name)) {
|
|
340
333
|
return null;
|
|
341
334
|
}
|
|
342
335
|
let directiveMetadata = null;
|
|
@@ -372,7 +365,7 @@ function extractDtsInput(node, metadataReader) {
|
|
|
372
365
|
*/
|
|
373
366
|
function extractSourceCodeInput(node, host, reflector, evaluator) {
|
|
374
367
|
if (!index.isInputContainerNode(node) ||
|
|
375
|
-
!
|
|
368
|
+
!ts.isIdentifier(node.name) ||
|
|
376
369
|
node.getSourceFile().isDeclarationFile) {
|
|
377
370
|
return null;
|
|
378
371
|
}
|
|
@@ -440,7 +433,7 @@ function parseTransformOfInput(evaluatedInputOpts, node, reflector) {
|
|
|
440
433
|
},
|
|
441
434
|
]);
|
|
442
435
|
try {
|
|
443
|
-
return
|
|
436
|
+
return checker.parseDecoratorInputTransformFunction(node.parent, node.name.text, transformValue, reflector, noopRefEmitter, checker.CompilationMode.FULL);
|
|
444
437
|
}
|
|
445
438
|
catch (e) {
|
|
446
439
|
if (!(e instanceof checker.FatalDiagnosticError)) {
|
|
@@ -464,16 +457,16 @@ function parseTransformOfInput(evaluatedInputOpts, node, reflector) {
|
|
|
464
457
|
*/
|
|
465
458
|
function prepareAndCheckForConversion(node, metadata, checker, options) {
|
|
466
459
|
// Accessor inputs cannot be migrated right now.
|
|
467
|
-
if (
|
|
460
|
+
if (ts.isAccessor(node)) {
|
|
468
461
|
return {
|
|
469
462
|
context: node,
|
|
470
463
|
reason: migrate_ts_type_references.FieldIncompatibilityReason.Accessor,
|
|
471
464
|
};
|
|
472
465
|
}
|
|
473
|
-
|
|
466
|
+
assert(metadata.inputDecorator !== null, 'Expected an input decorator for inputs that are being migrated.');
|
|
474
467
|
let initialValue = node.initializer;
|
|
475
468
|
let isUndefinedInitialValue = node.initializer === undefined ||
|
|
476
|
-
(
|
|
469
|
+
(ts.isIdentifier(node.initializer) && node.initializer.text === 'undefined');
|
|
477
470
|
const strictNullChecksEnabled = options.strict === true || options.strictNullChecks === true;
|
|
478
471
|
const strictPropertyInitialization = options.strict === true || options.strictPropertyInitialization === true;
|
|
479
472
|
// Shorthand should never be used, as would expand the type of `T` to be `T|undefined`.
|
|
@@ -515,9 +508,9 @@ function prepareAndCheckForConversion(node, metadata, checker, options) {
|
|
|
515
508
|
};
|
|
516
509
|
}
|
|
517
510
|
if (!checker.isTypeAssignableTo(checker.getUndefinedType(), checker.getTypeFromTypeNode(typeToAdd))) {
|
|
518
|
-
typeToAdd =
|
|
511
|
+
typeToAdd = ts.factory.createUnionTypeNode([
|
|
519
512
|
typeToAdd,
|
|
520
|
-
|
|
513
|
+
ts.factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword),
|
|
521
514
|
]);
|
|
522
515
|
}
|
|
523
516
|
}
|
|
@@ -538,7 +531,7 @@ function prepareAndCheckForConversion(node, metadata, checker, options) {
|
|
|
538
531
|
'Input is initialized to `undefined` but type does not allow this value. ' +
|
|
539
532
|
'This worked with `@Input` because your project uses `--strictPropertyInitialization=false`.';
|
|
540
533
|
isUndefinedInitialValue = false;
|
|
541
|
-
initialValue =
|
|
534
|
+
initialValue = ts.factory.createNonNullExpression(ts.factory.createIdentifier('undefined'));
|
|
542
535
|
}
|
|
543
536
|
// Attempt to extract type from input initial value. No explicit type, but input is required.
|
|
544
537
|
// Hence we need an explicit type, or fall back to `typeof`.
|
|
@@ -572,28 +565,28 @@ function inferImportableTypeForInput(checker, node, initialValue) {
|
|
|
572
565
|
// return a type node fully derived from the resolved type.
|
|
573
566
|
if (isPrimitiveImportableTypeNode(propertyType) ||
|
|
574
567
|
(propertyType.isUnion() && propertyType.types.every(isPrimitiveImportableTypeNode))) {
|
|
575
|
-
return checker.typeToTypeNode(propertyType, node,
|
|
568
|
+
return checker.typeToTypeNode(propertyType, node, ts.NodeBuilderFlags.NoTypeReduction) ?? null;
|
|
576
569
|
}
|
|
577
570
|
// Alternatively, try to infer a simple importable type from\
|
|
578
571
|
// the initializer.
|
|
579
|
-
if (
|
|
572
|
+
if (ts.isIdentifier(initialValue)) {
|
|
580
573
|
// @Input({required: true}) bla = SOME_DEFAULT;
|
|
581
|
-
return
|
|
574
|
+
return ts.factory.createTypeQueryNode(initialValue);
|
|
582
575
|
}
|
|
583
|
-
else if (
|
|
584
|
-
|
|
585
|
-
|
|
576
|
+
else if (ts.isPropertyAccessExpression(initialValue) &&
|
|
577
|
+
ts.isIdentifier(initialValue.name) &&
|
|
578
|
+
ts.isIdentifier(initialValue.expression)) {
|
|
586
579
|
// @Input({required: true}) bla = prop.SOME_DEFAULT;
|
|
587
|
-
return
|
|
580
|
+
return ts.factory.createTypeQueryNode(ts.factory.createQualifiedName(initialValue.name, initialValue.expression));
|
|
588
581
|
}
|
|
589
582
|
return null;
|
|
590
583
|
}
|
|
591
584
|
function isPrimitiveImportableTypeNode(type) {
|
|
592
|
-
return !!(type.flags &
|
|
593
|
-
type.flags &
|
|
594
|
-
type.flags &
|
|
595
|
-
type.flags &
|
|
596
|
-
type.flags &
|
|
585
|
+
return !!(type.flags & ts.TypeFlags.BooleanLike ||
|
|
586
|
+
type.flags & ts.TypeFlags.StringLike ||
|
|
587
|
+
type.flags & ts.TypeFlags.NumberLike ||
|
|
588
|
+
type.flags & ts.TypeFlags.Undefined ||
|
|
589
|
+
type.flags & ts.TypeFlags.Null);
|
|
597
590
|
}
|
|
598
591
|
|
|
599
592
|
/**
|
|
@@ -604,7 +597,7 @@ function pass1__IdentifySourceFileAndDeclarationInputs(sf, host, checker, reflec
|
|
|
604
597
|
const visitor = (node) => {
|
|
605
598
|
const decoratorInput = extractDecoratorInput(node, host, reflector, dtsMetadataReader, evaluator);
|
|
606
599
|
if (decoratorInput !== null) {
|
|
607
|
-
|
|
600
|
+
assert(index.isInputContainerNode(node), 'Expected input to be declared on accessor or property.');
|
|
608
601
|
const inputDescr = getInputDescriptor(host, node);
|
|
609
602
|
// track all inputs, even from declarations for reference resolution.
|
|
610
603
|
knownDecoratorInputs.register({ descriptor: inputDescr, metadata: decoratorInput, node });
|
|
@@ -623,10 +616,10 @@ function pass1__IdentifySourceFileAndDeclarationInputs(sf, host, checker, reflec
|
|
|
623
616
|
}
|
|
624
617
|
// track all imports to `Input` or `input`.
|
|
625
618
|
let importName = null;
|
|
626
|
-
if (
|
|
619
|
+
if (ts.isImportSpecifier(node) &&
|
|
627
620
|
((importName = (node.propertyName ?? node.name).text) === 'Input' ||
|
|
628
621
|
importName === 'input') &&
|
|
629
|
-
|
|
622
|
+
ts.isStringLiteral(node.parent.parent.parent.moduleSpecifier) &&
|
|
630
623
|
(host.isMigratingCore || node.parent.parent.parent.moduleSpecifier.text === '@angular/core')) {
|
|
631
624
|
if (!result.inputDecoratorSpecifiers.has(sf)) {
|
|
632
625
|
result.inputDecoratorSpecifiers.set(sf, []);
|
|
@@ -636,9 +629,9 @@ function pass1__IdentifySourceFileAndDeclarationInputs(sf, host, checker, reflec
|
|
|
636
629
|
node,
|
|
637
630
|
});
|
|
638
631
|
}
|
|
639
|
-
|
|
632
|
+
ts.forEachChild(node, visitor);
|
|
640
633
|
};
|
|
641
|
-
|
|
634
|
+
ts.forEachChild(sf, visitor);
|
|
642
635
|
}
|
|
643
636
|
|
|
644
637
|
/**
|
|
@@ -767,7 +760,7 @@ function pass4__checkInheritanceOfInputs(inheritanceGraph, metaRegistry, knownIn
|
|
|
767
760
|
isClassWithKnownFields: (clazz) => knownInputs.isInputContainingClass(clazz),
|
|
768
761
|
getFieldsForClass: (clazz) => {
|
|
769
762
|
const directiveInfo = knownInputs.getDirectiveInfoForClass(clazz);
|
|
770
|
-
|
|
763
|
+
assert(directiveInfo !== undefined, 'Expected directive info to exist for input.');
|
|
771
764
|
return Array.from(directiveInfo.inputFields.values()).map((i) => i.descriptor);
|
|
772
765
|
},
|
|
773
766
|
});
|
|
@@ -974,7 +967,7 @@ function convertToSignalInput(node, { resolvedMetadata: metadata, resolvedType,
|
|
|
974
967
|
if (metadata.bindingPropertyName !== metadata.classPropertyName || metadata.transform !== null) {
|
|
975
968
|
const properties = [];
|
|
976
969
|
if (metadata.bindingPropertyName !== metadata.classPropertyName) {
|
|
977
|
-
properties.push(
|
|
970
|
+
properties.push(ts.factory.createPropertyAssignment('alias', ts.factory.createStringLiteral(metadata.bindingPropertyName)));
|
|
978
971
|
}
|
|
979
972
|
if (metadata.transform !== null) {
|
|
980
973
|
const transformRes = extractTransformOfInput(metadata.transform, resolvedType, checker);
|
|
@@ -985,7 +978,7 @@ function convertToSignalInput(node, { resolvedMetadata: metadata, resolvedType,
|
|
|
985
978
|
(leadingTodoText ? `${leadingTodoText} ` : '') + transformRes.leadingTodoText;
|
|
986
979
|
}
|
|
987
980
|
}
|
|
988
|
-
optionsLiteral =
|
|
981
|
+
optionsLiteral = ts.factory.createObjectLiteralExpression(properties);
|
|
989
982
|
}
|
|
990
983
|
// The initial value is `undefined` or none is present:
|
|
991
984
|
// - We may be able to use the `input()` shorthand
|
|
@@ -993,14 +986,14 @@ function convertToSignalInput(node, { resolvedMetadata: metadata, resolvedType,
|
|
|
993
986
|
if (initialValue === undefined) {
|
|
994
987
|
// Shorthand not possible, so explicitly add `undefined`.
|
|
995
988
|
if (preferShorthandIfPossible === null) {
|
|
996
|
-
initialValue =
|
|
989
|
+
initialValue = ts.factory.createIdentifier('undefined');
|
|
997
990
|
}
|
|
998
991
|
else {
|
|
999
992
|
resolvedType = preferShorthandIfPossible.originalType;
|
|
1000
993
|
// When using the `input()` shorthand, try cutting of `undefined` from potential
|
|
1001
994
|
// union types. `undefined` will be automatically included in the type.
|
|
1002
|
-
if (
|
|
1003
|
-
resolvedType = migrate_ts_type_references.removeFromUnionIfPossible(resolvedType, (t) => t.kind !==
|
|
995
|
+
if (ts.isUnionTypeNode(resolvedType)) {
|
|
996
|
+
resolvedType = migrate_ts_type_references.removeFromUnionIfPossible(resolvedType, (t) => t.kind !== ts.SyntaxKind.UndefinedKeyword);
|
|
1004
997
|
}
|
|
1005
998
|
}
|
|
1006
999
|
}
|
|
@@ -1011,13 +1004,13 @@ function convertToSignalInput(node, { resolvedMetadata: metadata, resolvedType,
|
|
|
1011
1004
|
if (metadata.transform !== null) {
|
|
1012
1005
|
// Note: The TCB code generation may use the same type node and attach
|
|
1013
1006
|
// synthetic comments for error reporting. We remove those explicitly here.
|
|
1014
|
-
typeArguments.push(
|
|
1007
|
+
typeArguments.push(ts.setSyntheticTrailingComments(metadata.transform.type.node, undefined));
|
|
1015
1008
|
}
|
|
1016
1009
|
}
|
|
1017
1010
|
// Always add an initial value when the input is optional, and we have one, or we need one
|
|
1018
1011
|
// to be able to pass options as the second argument.
|
|
1019
1012
|
if (!metadata.required && (initialValue !== undefined || optionsLiteral !== null)) {
|
|
1020
|
-
inputArgs.push(initialValue ??
|
|
1013
|
+
inputArgs.push(initialValue ?? ts.factory.createIdentifier('undefined'));
|
|
1021
1014
|
}
|
|
1022
1015
|
if (optionsLiteral !== null) {
|
|
1023
1016
|
inputArgs.push(optionsLiteral);
|
|
@@ -1028,16 +1021,16 @@ function convertToSignalInput(node, { resolvedMetadata: metadata, resolvedType,
|
|
|
1028
1021
|
requestedFile: node.getSourceFile(),
|
|
1029
1022
|
});
|
|
1030
1023
|
const inputInitializerFn = metadata.required
|
|
1031
|
-
?
|
|
1024
|
+
? ts.factory.createPropertyAccessExpression(inputFnRef, 'required')
|
|
1032
1025
|
: inputFnRef;
|
|
1033
|
-
const inputInitializer =
|
|
1026
|
+
const inputInitializer = ts.factory.createCallExpression(inputInitializerFn, typeArguments, inputArgs);
|
|
1034
1027
|
let modifiersWithoutInputDecorator = node.modifiers?.filter((m) => m !== originalInputDecorator.node) ?? [];
|
|
1035
1028
|
// Add `readonly` to all new signal input declarations.
|
|
1036
|
-
if (!modifiersWithoutInputDecorator?.some((s) => s.kind ===
|
|
1037
|
-
modifiersWithoutInputDecorator.push(
|
|
1029
|
+
if (!modifiersWithoutInputDecorator?.some((s) => s.kind === ts.SyntaxKind.ReadonlyKeyword)) {
|
|
1030
|
+
modifiersWithoutInputDecorator.push(ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword));
|
|
1038
1031
|
}
|
|
1039
|
-
const newNode =
|
|
1040
|
-
const newPropertyText = result.printer.printNode(
|
|
1032
|
+
const newNode = ts.factory.createPropertyDeclaration(modifiersWithoutInputDecorator, node.name, undefined, undefined, inputInitializer);
|
|
1033
|
+
const newPropertyText = result.printer.printNode(ts.EmitHint.Unspecified, newNode, node.getSourceFile());
|
|
1041
1034
|
const replacements = [];
|
|
1042
1035
|
if (leadingTodoText !== null) {
|
|
1043
1036
|
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}`)));
|
|
@@ -1054,29 +1047,29 @@ function convertToSignalInput(node, { resolvedMetadata: metadata, resolvedType,
|
|
|
1054
1047
|
* that works for the new signal `input()` API.
|
|
1055
1048
|
*/
|
|
1056
1049
|
function extractTransformOfInput(transform, resolvedType, checker) {
|
|
1057
|
-
|
|
1050
|
+
assert(ts.isExpression(transform.node), `Expected transform to be an expression.`);
|
|
1058
1051
|
let transformFn = transform.node;
|
|
1059
1052
|
let leadingTodoText = null;
|
|
1060
1053
|
// If there is an explicit type, check if the transform return type actually works.
|
|
1061
1054
|
// In some cases, the transform function is not compatible because with decorator inputs,
|
|
1062
1055
|
// those were not checked. We cast the transform to `any` and add a TODO.
|
|
1063
1056
|
// TODO: Capture this in the design doc.
|
|
1064
|
-
if (resolvedType !== undefined && !
|
|
1057
|
+
if (resolvedType !== undefined && !ts.isSyntheticExpression(resolvedType)) {
|
|
1065
1058
|
// Note: If the type is synthetic, we cannot check, and we accept that in the worst case
|
|
1066
1059
|
// we will create code that is not necessarily compiling. This is unlikely, but notably
|
|
1067
1060
|
// the errors would be correct and valuable.
|
|
1068
1061
|
const transformType = checker.getTypeAtLocation(transform.node);
|
|
1069
1062
|
const transformSignature = transformType.getCallSignatures()[0];
|
|
1070
|
-
|
|
1063
|
+
assert(transformSignature !== undefined, 'Expected transform to be an invoke-able.');
|
|
1071
1064
|
if (!checker.isTypeAssignableTo(checker.getReturnTypeOfSignature(transformSignature), checker.getTypeFromTypeNode(resolvedType))) {
|
|
1072
1065
|
leadingTodoText =
|
|
1073
1066
|
'Input type is incompatible with transform. The migration added an `any` cast. ' +
|
|
1074
1067
|
'This worked previously because Angular was unable to check transforms.';
|
|
1075
|
-
transformFn =
|
|
1068
|
+
transformFn = ts.factory.createAsExpression(ts.factory.createParenthesizedExpression(transformFn), ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword));
|
|
1076
1069
|
}
|
|
1077
1070
|
}
|
|
1078
1071
|
return {
|
|
1079
|
-
node:
|
|
1072
|
+
node: ts.factory.createPropertyAssignment('transform', transformFn),
|
|
1080
1073
|
leadingTodoText,
|
|
1081
1074
|
};
|
|
1082
1075
|
}
|
|
@@ -1104,8 +1097,8 @@ function pass6__migrateInputDeclarations(host, checker, result, knownInputs, imp
|
|
|
1104
1097
|
filesWithIncompatibleInputs.add(sf);
|
|
1105
1098
|
continue;
|
|
1106
1099
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1100
|
+
assert(metadata !== null, `Expected metadata to exist for input isn't marked incompatible.`);
|
|
1101
|
+
assert(!ts.isAccessor(input.node), 'Accessor inputs are incompatible.');
|
|
1109
1102
|
filesWithMigratedInputs.add(sf);
|
|
1110
1103
|
result.replacements.push(...convertToSignalInput(input.node, metadata, info, checker, importManager, result));
|
|
1111
1104
|
}
|
|
@@ -1,36 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
4
|
-
* (c) 2010-
|
|
3
|
+
* @license Angular v20.0.0-next.2
|
|
4
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10
|
-
|
|
11
9
|
var schematics = require('@angular-devkit/schematics');
|
|
12
|
-
var project_tsconfig_paths = require('./project_tsconfig_paths-
|
|
13
|
-
var project_paths = require('./project_paths-
|
|
10
|
+
var project_tsconfig_paths = require('./project_tsconfig_paths-CDVxT6Ov.js');
|
|
11
|
+
var project_paths = require('./project_paths-Jtbi76Bs.js');
|
|
14
12
|
require('os');
|
|
15
13
|
var ts = require('typescript');
|
|
16
|
-
var checker = require('./checker-
|
|
17
|
-
var program = require('./program-
|
|
14
|
+
var checker = require('./checker-DF8ZaFW5.js');
|
|
15
|
+
var program = require('./program-BZk27Ndu.js');
|
|
18
16
|
require('path');
|
|
19
|
-
var apply_import_manager = require('./apply_import_manager-
|
|
20
|
-
var migrate_ts_type_references = require('./migrate_ts_type_references-
|
|
17
|
+
var apply_import_manager = require('./apply_import_manager-CyRT0UvU.js');
|
|
18
|
+
var migrate_ts_type_references = require('./migrate_ts_type_references-DtkOnnv0.js');
|
|
21
19
|
var assert = require('assert');
|
|
22
|
-
var index = require('./index-
|
|
20
|
+
var index = require('./index-DnkWgagp.js');
|
|
23
21
|
require('@angular-devkit/core');
|
|
24
22
|
require('node:path/posix');
|
|
25
23
|
require('fs');
|
|
26
24
|
require('module');
|
|
27
25
|
require('url');
|
|
28
|
-
require('./leading_space-
|
|
29
|
-
|
|
30
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
31
|
-
|
|
32
|
-
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
33
|
-
var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
|
|
26
|
+
require('./leading_space-D9nQ8UQC.js');
|
|
34
27
|
|
|
35
28
|
/**
|
|
36
29
|
* Phase that migrates Angular host binding references to
|
|
@@ -106,14 +99,14 @@ function migrateTemplateReferences(host, references) {
|
|
|
106
99
|
*/
|
|
107
100
|
function extractQueryListType(node) {
|
|
108
101
|
// Initializer variant of `new QueryList<T>()`.
|
|
109
|
-
if (
|
|
110
|
-
|
|
102
|
+
if (ts.isNewExpression(node) &&
|
|
103
|
+
ts.isIdentifier(node.expression) &&
|
|
111
104
|
node.expression.text === 'QueryList') {
|
|
112
105
|
return node.typeArguments?.[0];
|
|
113
106
|
}
|
|
114
107
|
// Type variant of `: QueryList<T>`.
|
|
115
|
-
if (
|
|
116
|
-
|
|
108
|
+
if (ts.isTypeReferenceNode(node) &&
|
|
109
|
+
ts.isIdentifier(node.typeName) &&
|
|
117
110
|
node.typeName.text === 'QueryList') {
|
|
118
111
|
return node.typeArguments?.[0];
|
|
119
112
|
}
|
|
@@ -166,14 +159,14 @@ function computeReplacementsToMigrateQuery(node, metadata, importManager, info,
|
|
|
166
159
|
}
|
|
167
160
|
}
|
|
168
161
|
if (metadata.queryInfo.read !== null) {
|
|
169
|
-
|
|
170
|
-
optionProperties.push(
|
|
162
|
+
assert(metadata.queryInfo.read instanceof checker.WrappedNodeExpr);
|
|
163
|
+
optionProperties.push(ts.factory.createPropertyAssignment('read', metadata.queryInfo.read.node));
|
|
171
164
|
}
|
|
172
165
|
if (metadata.queryInfo.descendants !== defaultDescendants) {
|
|
173
|
-
optionProperties.push(
|
|
166
|
+
optionProperties.push(ts.factory.createPropertyAssignment('descendants', metadata.queryInfo.descendants ? ts.factory.createTrue() : ts.factory.createFalse()));
|
|
174
167
|
}
|
|
175
168
|
if (optionProperties.length > 0) {
|
|
176
|
-
args.push(
|
|
169
|
+
args.push(ts.factory.createObjectLiteralExpression(optionProperties));
|
|
177
170
|
}
|
|
178
171
|
const strictNullChecksEnabled = options.strict === true || options.strictNullChecks === true;
|
|
179
172
|
const strictPropertyInitialization = options.strict === true || options.strictPropertyInitialization === true;
|
|
@@ -196,12 +189,12 @@ function computeReplacementsToMigrateQuery(node, metadata, importManager, info,
|
|
|
196
189
|
if (isRequired && metadata.queryInfo.first) {
|
|
197
190
|
// If the query is required already via some indicators, and this is a "single"
|
|
198
191
|
// query, use the available `.required` method.
|
|
199
|
-
newQueryFn =
|
|
192
|
+
newQueryFn = ts.factory.createPropertyAccessExpression(newQueryFn, 'required');
|
|
200
193
|
}
|
|
201
194
|
// If this query is still nullable (i.e. not required), attempt to remove
|
|
202
195
|
// explicit `undefined` types if possible.
|
|
203
|
-
if (!isRequired && type !== undefined &&
|
|
204
|
-
type = migrate_ts_type_references.removeFromUnionIfPossible(type, (v) => v.kind !==
|
|
196
|
+
if (!isRequired && type !== undefined && ts.isUnionTypeNode(type)) {
|
|
197
|
+
type = migrate_ts_type_references.removeFromUnionIfPossible(type, (v) => v.kind !== ts.SyntaxKind.UndefinedKeyword);
|
|
205
198
|
}
|
|
206
199
|
let locatorType = Array.isArray(metadata.queryInfo.predicate)
|
|
207
200
|
? null
|
|
@@ -211,23 +204,23 @@ function computeReplacementsToMigrateQuery(node, metadata, importManager, info,
|
|
|
211
204
|
// on the TS inference, instead of repeating types, like in `viewChild<Button>(Button)`.
|
|
212
205
|
if (type !== undefined &&
|
|
213
206
|
resolvedReadType instanceof checker.WrappedNodeExpr &&
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
207
|
+
ts.isIdentifier(resolvedReadType.node) &&
|
|
208
|
+
ts.isTypeReferenceNode(type) &&
|
|
209
|
+
ts.isIdentifier(type.typeName) &&
|
|
217
210
|
type.typeName.text === resolvedReadType.node.text) {
|
|
218
211
|
locatorType = null;
|
|
219
212
|
}
|
|
220
|
-
const call =
|
|
213
|
+
const call = ts.factory.createCallExpression(newQueryFn,
|
|
221
214
|
// If there is no resolved `ReadT` (e.g. string predicate), we use the
|
|
222
215
|
// original type explicitly as generic. Otherwise, query API is smart
|
|
223
216
|
// enough to always infer.
|
|
224
217
|
resolvedReadType === null && type !== undefined ? [type] : undefined, args);
|
|
225
|
-
const updated =
|
|
218
|
+
const updated = ts.factory.createPropertyDeclaration([ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)], node.name, undefined, undefined, call);
|
|
226
219
|
return [
|
|
227
220
|
new project_paths.Replacement(project_paths.projectFile(node.getSourceFile(), info), new project_paths.TextUpdate({
|
|
228
221
|
position: node.getStart(),
|
|
229
222
|
end: node.getEnd(),
|
|
230
|
-
toInsert: printer.printNode(
|
|
223
|
+
toInsert: printer.printNode(ts.EmitHint.Unspecified, updated, sf),
|
|
231
224
|
})),
|
|
232
225
|
];
|
|
233
226
|
}
|
|
@@ -238,7 +231,7 @@ function computeReplacementsToMigrateQuery(node, metadata, importManager, info,
|
|
|
238
231
|
*/
|
|
239
232
|
function getClassFieldDescriptorForSymbol(symbol, info) {
|
|
240
233
|
if (symbol?.valueDeclaration === undefined ||
|
|
241
|
-
!
|
|
234
|
+
!ts.isPropertyDeclaration(symbol.valueDeclaration)) {
|
|
242
235
|
return null;
|
|
243
236
|
}
|
|
244
237
|
const key = getUniqueIDForClassProperty(symbol.valueDeclaration, info);
|
|
@@ -259,7 +252,7 @@ function getClassFieldDescriptorForSymbol(symbol, info) {
|
|
|
259
252
|
* would then match identity.
|
|
260
253
|
*/
|
|
261
254
|
function getUniqueIDForClassProperty(property, info) {
|
|
262
|
-
if (!
|
|
255
|
+
if (!ts.isClassDeclaration(property.parent) || property.parent.name === undefined) {
|
|
263
256
|
return null;
|
|
264
257
|
}
|
|
265
258
|
if (property.name === undefined) {
|
|
@@ -279,14 +272,14 @@ function getUniqueIDForClassProperty(property, info) {
|
|
|
279
272
|
* returns its resolved metadata if possible.
|
|
280
273
|
*/
|
|
281
274
|
function extractSourceQueryDefinition(node, reflector, evaluator, info) {
|
|
282
|
-
if ((!
|
|
283
|
-
!
|
|
275
|
+
if ((!ts.isPropertyDeclaration(node) && !ts.isAccessor(node)) ||
|
|
276
|
+
!ts.isClassDeclaration(node.parent) ||
|
|
284
277
|
node.parent.name === undefined ||
|
|
285
|
-
!
|
|
278
|
+
!ts.isIdentifier(node.name)) {
|
|
286
279
|
return null;
|
|
287
280
|
}
|
|
288
281
|
const decorators = reflector.getDecoratorsOfDeclaration(node) ?? [];
|
|
289
|
-
const ngDecorators = checker.getAngularDecorators(decorators,
|
|
282
|
+
const ngDecorators = checker.getAngularDecorators(decorators, checker.queryDecoratorNames, /* isCore */ false);
|
|
290
283
|
if (ngDecorators.length === 0) {
|
|
291
284
|
return null;
|
|
292
285
|
}
|
|
@@ -313,7 +306,7 @@ function extractSourceQueryDefinition(node, reflector, evaluator, info) {
|
|
|
313
306
|
}
|
|
314
307
|
let queryInfo = null;
|
|
315
308
|
try {
|
|
316
|
-
queryInfo =
|
|
309
|
+
queryInfo = checker.extractDecoratorQueryMetadata(node, decorator.name, decorator.args ?? [], node.name.text, reflector, evaluator);
|
|
317
310
|
}
|
|
318
311
|
catch (e) {
|
|
319
312
|
if (!(e instanceof checker.FatalDiagnosticError)) {
|
|
@@ -412,7 +405,7 @@ class KnownQueries {
|
|
|
412
405
|
return this.classToQueryFields.get(clazz);
|
|
413
406
|
}
|
|
414
407
|
getAllClassesWithQueries() {
|
|
415
|
-
return Array.from(this.classToQueryFields.keys()).filter((c) =>
|
|
408
|
+
return Array.from(this.classToQueryFields.keys()).filter((c) => ts.isClassDeclaration(c));
|
|
416
409
|
}
|
|
417
410
|
captureKnownFieldInheritanceRelationship(derived, parent) {
|
|
418
411
|
// Note: The edge problematic pattern recognition is not as good as the one
|
|
@@ -505,8 +498,8 @@ function queryFunctionNameToDecorator(name) {
|
|
|
505
498
|
function checkTsReferenceAccessesField(ref, fieldName) {
|
|
506
499
|
const accessNode = index.traverseAccess(ref.from.node);
|
|
507
500
|
// Check if the reference is part of a property access.
|
|
508
|
-
if (!
|
|
509
|
-
!
|
|
501
|
+
if (!ts.isPropertyAccessExpression(accessNode.parent) ||
|
|
502
|
+
!ts.isIdentifier(accessNode.parent.name)) {
|
|
510
503
|
return null;
|
|
511
504
|
}
|
|
512
505
|
// Check if the reference is refers to the given field name.
|
|
@@ -543,7 +536,7 @@ function checkTsReferenceCallsField(ref, fieldName) {
|
|
|
543
536
|
if (propertyAccess === null) {
|
|
544
537
|
return null;
|
|
545
538
|
}
|
|
546
|
-
if (
|
|
539
|
+
if (ts.isCallExpression(propertyAccess.parent) &&
|
|
547
540
|
propertyAccess.parent.expression === propertyAccess) {
|
|
548
541
|
return propertyAccess.parent;
|
|
549
542
|
}
|
|
@@ -769,17 +762,17 @@ class SignalQueriesMigration extends project_paths.TsurgeComplexMigration {
|
|
|
769
762
|
fieldName: extractedQuery.queryInfo.propertyName,
|
|
770
763
|
isMulti: extractedQuery.queryInfo.first === false,
|
|
771
764
|
};
|
|
772
|
-
if (
|
|
765
|
+
if (ts.isAccessor(queryNode)) {
|
|
773
766
|
markFieldIncompatibleInMetadata(res.potentialProblematicQueries, extractedQuery.id, migrate_ts_type_references.FieldIncompatibilityReason.Accessor);
|
|
774
767
|
}
|
|
775
768
|
// Detect queries with union types that are uncommon to be
|
|
776
769
|
// automatically migrate-able. E.g. `refs: ElementRef|null`,
|
|
777
770
|
// or `ElementRef|SomeOtherType`.
|
|
778
771
|
if (queryNode.type !== undefined &&
|
|
779
|
-
|
|
772
|
+
ts.isUnionTypeNode(queryNode.type) &&
|
|
780
773
|
// Either too large union, or doesn't match `T|undefined`.
|
|
781
774
|
(queryNode.type.types.length > 2 ||
|
|
782
|
-
!queryNode.type.types.some((t) => t.kind ===
|
|
775
|
+
!queryNode.type.types.some((t) => t.kind === ts.SyntaxKind.UndefinedKeyword))) {
|
|
783
776
|
markFieldIncompatibleInMetadata(res.potentialProblematicQueries, extractedQuery.id, migrate_ts_type_references.FieldIncompatibilityReason.SignalQueries__IncompatibleMultiUnionType);
|
|
784
777
|
}
|
|
785
778
|
// Migrating fields with `@HostBinding` is incompatible as
|
|
@@ -927,7 +920,7 @@ class SignalQueriesMigration extends project_paths.TsurgeComplexMigration {
|
|
|
927
920
|
const evaluator = new program.PartialEvaluator(reflector, checker$1, null);
|
|
928
921
|
const replacements = [];
|
|
929
922
|
const importManager = new checker.ImportManager();
|
|
930
|
-
const printer =
|
|
923
|
+
const printer = ts.createPrinter();
|
|
931
924
|
const filesWithSourceQueries = new Map();
|
|
932
925
|
const filesWithIncompleteMigration = new Map();
|
|
933
926
|
const filesWithQueryListOutsideOfDeclarations = new WeakSet();
|
|
@@ -944,8 +937,8 @@ class SignalQueriesMigration extends project_paths.TsurgeComplexMigration {
|
|
|
944
937
|
return;
|
|
945
938
|
}
|
|
946
939
|
// Detect OTHER queries, inside `.d.ts`. Needed for reference resolution below.
|
|
947
|
-
if (
|
|
948
|
-
(
|
|
940
|
+
if (ts.isPropertyDeclaration(node) ||
|
|
941
|
+
(ts.isAccessor(node) && ts.isClassDeclaration(node.parent))) {
|
|
949
942
|
const classFieldID = getUniqueIDForClassProperty(node, info);
|
|
950
943
|
if (classFieldID !== null && globalMetadata.knownQueryFields[classFieldID] !== undefined) {
|
|
951
944
|
knownQueries.registerQueryField(node, classFieldID);
|
|
@@ -954,15 +947,15 @@ class SignalQueriesMigration extends project_paths.TsurgeComplexMigration {
|
|
|
954
947
|
}
|
|
955
948
|
// Detect potential usages of `QueryList` outside of queries or imports.
|
|
956
949
|
// Those prevent us from removing the import later.
|
|
957
|
-
if (
|
|
950
|
+
if (ts.isIdentifier(node) &&
|
|
958
951
|
node.text === 'QueryList' &&
|
|
959
|
-
|
|
952
|
+
ts.findAncestor(node, ts.isImportDeclaration) === undefined) {
|
|
960
953
|
filesWithQueryListOutsideOfDeclarations.add(node.getSourceFile());
|
|
961
954
|
}
|
|
962
|
-
|
|
955
|
+
ts.forEachChild(node, queryWholeProgramVisitor);
|
|
963
956
|
};
|
|
964
957
|
for (const sf of info.fullProgramSourceFiles) {
|
|
965
|
-
|
|
958
|
+
ts.forEachChild(sf, queryWholeProgramVisitor);
|
|
966
959
|
}
|
|
967
960
|
// Set of all queries in the program. Useful for speeding up reference
|
|
968
961
|
// lookups below.
|