@angular/compiler-cli 21.0.0-next.7 → 21.0.0-next.9
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/bundles/{chunk-O7L4BBZY.js → chunk-3UF7UI6H.js} +233 -38
- package/bundles/chunk-DT6FD4OE.js +1 -1
- package/bundles/{chunk-WX6HCNBV.js → chunk-HRLHX4UA.js} +1 -1
- package/bundles/{chunk-CXWG7H5K.js → chunk-IE2YQNTQ.js} +1 -1
- package/bundles/{chunk-3I7LEC2O.js → chunk-SIOKS4LN.js} +367 -242
- package/bundles/index.js +4 -4
- package/bundles/private/migrations.js +1 -1
- package/bundles/private/tooling.js +2 -2
- package/bundles/src/bin/ng_xi18n.js +4 -4
- package/bundles/src/bin/ngc.js +4 -4
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/package.json +2 -2
- package/src/ngtsc/annotations/common/src/metadata.d.ts +5 -3
- package/src/ngtsc/annotations/component/src/handler.d.ts +1 -0
- package/src/ngtsc/annotations/directive/src/handler.d.ts +1 -0
- package/src/ngtsc/annotations/directive/src/shared.d.ts +6 -1
- package/src/ngtsc/diagnostics/src/error_code.d.ts +11 -0
- package/src/ngtsc/diagnostics/src/extended_template_diagnostic_name.d.ts +2 -1
- package/src/ngtsc/docs/src/class_extractor.d.ts +4 -5
- package/src/ngtsc/docs/src/entities.d.ts +7 -2
- package/src/ngtsc/docs/src/interface_extractor.d.ts +11 -0
- package/src/ngtsc/docs/src/properties_extractor.d.ts +96 -0
- package/src/ngtsc/typecheck/api/checker.d.ts +4 -0
- package/src/ngtsc/typecheck/extended/api/api.d.ts +0 -10
- package/src/ngtsc/typecheck/extended/checks/defer_trigger_misconfiguration/index.d.ts +10 -0
- package/src/ngtsc/typecheck/src/checker.d.ts +1 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
angularJitApplicationTransform
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HRLHX4UA.js";
|
|
8
8
|
import {
|
|
9
9
|
AbsoluteModuleStrategy,
|
|
10
10
|
ActivePerfRecorder,
|
|
@@ -92,7 +92,7 @@ import {
|
|
|
92
92
|
toUnredirectedSourceFile,
|
|
93
93
|
tryParseInitializerApi,
|
|
94
94
|
untagAllTsFiles
|
|
95
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-3UF7UI6H.js";
|
|
96
96
|
import {
|
|
97
97
|
LogicalFileSystem,
|
|
98
98
|
absoluteFrom,
|
|
@@ -180,28 +180,10 @@ function isDocEntryWithSourceInfo(entry) {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
// packages/compiler-cli/src/ngtsc/docs/src/extractor.js
|
|
183
|
-
import
|
|
183
|
+
import ts14 from "typescript";
|
|
184
184
|
|
|
185
185
|
// packages/compiler-cli/src/ngtsc/docs/src/class_extractor.js
|
|
186
|
-
import
|
|
187
|
-
|
|
188
|
-
// packages/compiler-cli/src/ngtsc/docs/src/filters.js
|
|
189
|
-
function isAngularPrivateName(name) {
|
|
190
|
-
const firstChar = name[0] ?? "";
|
|
191
|
-
return firstChar === "\u0275" || firstChar === "_";
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// packages/compiler-cli/src/ngtsc/docs/src/function_extractor.js
|
|
195
|
-
import ts4 from "typescript";
|
|
196
|
-
|
|
197
|
-
// packages/compiler-cli/src/ngtsc/docs/src/generics_extractor.js
|
|
198
|
-
function extractGenerics(declaration) {
|
|
199
|
-
return declaration.typeParameters?.map((typeParam) => ({
|
|
200
|
-
name: typeParam.name.getText(),
|
|
201
|
-
constraint: typeParam.constraint?.getText(),
|
|
202
|
-
default: typeParam.default?.getText()
|
|
203
|
-
})) ?? [];
|
|
204
|
-
}
|
|
186
|
+
import ts7 from "typescript";
|
|
205
187
|
|
|
206
188
|
// packages/compiler-cli/src/ngtsc/docs/src/jsdoc_extractor.js
|
|
207
189
|
import ts2 from "typescript";
|
|
@@ -244,6 +226,27 @@ function unescapeAngularDecorators(comment) {
|
|
|
244
226
|
return comment.replace(/_NG_AT_/g, "@");
|
|
245
227
|
}
|
|
246
228
|
|
|
229
|
+
// packages/compiler-cli/src/ngtsc/docs/src/properties_extractor.js
|
|
230
|
+
import ts6 from "typescript";
|
|
231
|
+
|
|
232
|
+
// packages/compiler-cli/src/ngtsc/docs/src/filters.js
|
|
233
|
+
function isAngularPrivateName(name) {
|
|
234
|
+
const firstChar = name[0] ?? "";
|
|
235
|
+
return firstChar === "\u0275" || firstChar === "_";
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// packages/compiler-cli/src/ngtsc/docs/src/function_extractor.js
|
|
239
|
+
import ts4 from "typescript";
|
|
240
|
+
|
|
241
|
+
// packages/compiler-cli/src/ngtsc/docs/src/generics_extractor.js
|
|
242
|
+
function extractGenerics(declaration) {
|
|
243
|
+
return declaration.typeParameters?.map((typeParam) => ({
|
|
244
|
+
name: typeParam.name.getText(),
|
|
245
|
+
constraint: typeParam.constraint?.getText(),
|
|
246
|
+
default: typeParam.default?.getText()
|
|
247
|
+
})) ?? [];
|
|
248
|
+
}
|
|
249
|
+
|
|
247
250
|
// packages/compiler-cli/src/ngtsc/docs/src/type_extractor.js
|
|
248
251
|
import ts3 from "typescript";
|
|
249
252
|
function extractResolvedTypeString(node, checker) {
|
|
@@ -381,8 +384,8 @@ function hasLeadingInternalComment(member) {
|
|
|
381
384
|
) ?? false;
|
|
382
385
|
}
|
|
383
386
|
|
|
384
|
-
// packages/compiler-cli/src/ngtsc/docs/src/
|
|
385
|
-
var
|
|
387
|
+
// packages/compiler-cli/src/ngtsc/docs/src/properties_extractor.js
|
|
388
|
+
var PropertiesExtractor = class {
|
|
386
389
|
declaration;
|
|
387
390
|
typeChecker;
|
|
388
391
|
constructor(declaration, typeChecker) {
|
|
@@ -392,16 +395,8 @@ var ClassExtractor = class {
|
|
|
392
395
|
/** Extract docs info specific to classes. */
|
|
393
396
|
extract() {
|
|
394
397
|
return {
|
|
395
|
-
name: this.declaration.name.text,
|
|
396
|
-
isAbstract: this.isAbstract(),
|
|
397
|
-
entryType: ts6.isInterfaceDeclaration(this.declaration) ? EntryType.Interface : EntryType.UndecoratedClass,
|
|
398
398
|
members: this.extractSignatures().concat(this.extractAllClassMembers()),
|
|
399
|
-
generics: extractGenerics(this.declaration)
|
|
400
|
-
description: extractJsDocDescription(this.declaration),
|
|
401
|
-
jsdocTags: extractJsDocTags(this.declaration),
|
|
402
|
-
rawComment: extractRawJsDoc(this.declaration),
|
|
403
|
-
extends: this.extractInheritance(this.declaration),
|
|
404
|
-
implements: this.extractInterfaceConformance(this.declaration)
|
|
399
|
+
generics: extractGenerics(this.declaration)
|
|
405
400
|
};
|
|
406
401
|
}
|
|
407
402
|
/** Extracts doc info for a class's members. */
|
|
@@ -478,21 +473,6 @@ var ClassExtractor = class {
|
|
|
478
473
|
memberTags: this.getMemberTags(constructorDeclaration)
|
|
479
474
|
};
|
|
480
475
|
}
|
|
481
|
-
extractInheritance(declaration) {
|
|
482
|
-
if (!declaration.heritageClauses) {
|
|
483
|
-
return void 0;
|
|
484
|
-
}
|
|
485
|
-
for (const clause of declaration.heritageClauses) {
|
|
486
|
-
if (clause.token === ts6.SyntaxKind.ExtendsKeyword) {
|
|
487
|
-
const types = clause.types;
|
|
488
|
-
if (types.length > 0) {
|
|
489
|
-
const baseClass = types[0];
|
|
490
|
-
return baseClass.getText();
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
return void 0;
|
|
495
|
-
}
|
|
496
476
|
extractInterfaceConformance(declaration) {
|
|
497
477
|
const implementClause = declaration.heritageClauses?.find((clause) => clause.token === ts6.SyntaxKind.ImplementsKeyword);
|
|
498
478
|
return implementClause?.types.map((m) => m.getText()) ?? [];
|
|
@@ -614,11 +594,6 @@ var ClassExtractor = class {
|
|
|
614
594
|
isDocumentableSignature(signature) {
|
|
615
595
|
return ts6.isConstructSignatureDeclaration(signature) || ts6.isCallSignatureDeclaration(signature);
|
|
616
596
|
}
|
|
617
|
-
/** Gets whether the declaration for this extractor is abstract. */
|
|
618
|
-
isAbstract() {
|
|
619
|
-
const modifiers = this.declaration.modifiers ?? [];
|
|
620
|
-
return modifiers.some((mod) => mod.kind === ts6.SyntaxKind.AbstractKeyword);
|
|
621
|
-
}
|
|
622
597
|
/**
|
|
623
598
|
* Check wether a member has a private computed property name like [ɵWRITABLE_SIGNAL]
|
|
624
599
|
*
|
|
@@ -628,6 +603,47 @@ var ClassExtractor = class {
|
|
|
628
603
|
return ts6.isComputedPropertyName(property.name) && property.name.expression.getText().startsWith("\u0275");
|
|
629
604
|
}
|
|
630
605
|
};
|
|
606
|
+
|
|
607
|
+
// packages/compiler-cli/src/ngtsc/docs/src/class_extractor.js
|
|
608
|
+
var ClassExtractor = class extends PropertiesExtractor {
|
|
609
|
+
constructor(declaration, typeChecker) {
|
|
610
|
+
super(declaration, typeChecker);
|
|
611
|
+
}
|
|
612
|
+
/** Extract docs info specific to classes. */
|
|
613
|
+
extract() {
|
|
614
|
+
return {
|
|
615
|
+
name: this.declaration.name.text,
|
|
616
|
+
isAbstract: this.isAbstract(),
|
|
617
|
+
entryType: EntryType.UndecoratedClass,
|
|
618
|
+
...super.extract(),
|
|
619
|
+
description: extractJsDocDescription(this.declaration),
|
|
620
|
+
jsdocTags: extractJsDocTags(this.declaration),
|
|
621
|
+
rawComment: extractRawJsDoc(this.declaration),
|
|
622
|
+
extends: this.extractInheritance(this.declaration),
|
|
623
|
+
implements: this.extractInterfaceConformance(this.declaration)
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
/** Gets whether the declaration for this extractor is abstract. */
|
|
627
|
+
isAbstract() {
|
|
628
|
+
const modifiers = this.declaration.modifiers ?? [];
|
|
629
|
+
return modifiers.some((mod) => mod.kind === ts7.SyntaxKind.AbstractKeyword);
|
|
630
|
+
}
|
|
631
|
+
extractInheritance(declaration) {
|
|
632
|
+
if (!declaration.heritageClauses) {
|
|
633
|
+
return void 0;
|
|
634
|
+
}
|
|
635
|
+
for (const clause of declaration.heritageClauses) {
|
|
636
|
+
if (clause.token === ts7.SyntaxKind.ExtendsKeyword) {
|
|
637
|
+
const types = clause.types;
|
|
638
|
+
if (types.length > 0) {
|
|
639
|
+
const baseClass = types[0];
|
|
640
|
+
return baseClass.getText();
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return void 0;
|
|
645
|
+
}
|
|
646
|
+
};
|
|
631
647
|
var DirectiveExtractor = class extends ClassExtractor {
|
|
632
648
|
reference;
|
|
633
649
|
metadata;
|
|
@@ -724,13 +740,9 @@ function extractClass(classDeclaration, metadataReader, typeChecker) {
|
|
|
724
740
|
}
|
|
725
741
|
return extractor.extract();
|
|
726
742
|
}
|
|
727
|
-
function extractInterface(declaration, typeChecker) {
|
|
728
|
-
const extractor = new ClassExtractor(declaration, typeChecker);
|
|
729
|
-
return extractor.extract();
|
|
730
|
-
}
|
|
731
743
|
function extractPipeSyntax(metadata, classDeclaration) {
|
|
732
744
|
const transformParams = classDeclaration.members.find((member) => {
|
|
733
|
-
return
|
|
745
|
+
return ts7.isMethodDeclaration(member) && member.name && ts7.isIdentifier(member.name) && member.name.getText() === "transform";
|
|
734
746
|
});
|
|
735
747
|
let paramNames = transformParams.parameters.slice(1).map((param) => {
|
|
736
748
|
return param.name.getText();
|
|
@@ -739,7 +751,7 @@ function extractPipeSyntax(metadata, classDeclaration) {
|
|
|
739
751
|
}
|
|
740
752
|
|
|
741
753
|
// packages/compiler-cli/src/ngtsc/docs/src/constant_extractor.js
|
|
742
|
-
import
|
|
754
|
+
import ts8 from "typescript";
|
|
743
755
|
var LITERAL_AS_ENUM_TAG = "object-literal-as-enum";
|
|
744
756
|
function extractConstant(declaration, typeChecker) {
|
|
745
757
|
const resolvedType = typeChecker.getBaseTypeOfLiteralType(typeChecker.getTypeAtLocation(declaration));
|
|
@@ -771,17 +783,17 @@ function isSyntheticAngularConstant(declaration) {
|
|
|
771
783
|
}
|
|
772
784
|
function extractLiteralPropertiesAsEnumMembers(declaration) {
|
|
773
785
|
let initializer = declaration.initializer;
|
|
774
|
-
while (initializer && (
|
|
786
|
+
while (initializer && (ts8.isAsExpression(initializer) || ts8.isParenthesizedExpression(initializer))) {
|
|
775
787
|
initializer = initializer.expression;
|
|
776
788
|
}
|
|
777
|
-
if (initializer === void 0 || !
|
|
778
|
-
throw new Error(`Declaration tagged with "${LITERAL_AS_ENUM_TAG}" must be initialized to an object literal, but received ${initializer ?
|
|
789
|
+
if (initializer === void 0 || !ts8.isObjectLiteralExpression(initializer)) {
|
|
790
|
+
throw new Error(`Declaration tagged with "${LITERAL_AS_ENUM_TAG}" must be initialized to an object literal, but received ${initializer ? ts8.SyntaxKind[initializer.kind] : "undefined"}`);
|
|
779
791
|
}
|
|
780
792
|
return initializer.properties.map((prop) => {
|
|
781
|
-
if (!
|
|
793
|
+
if (!ts8.isPropertyAssignment(prop) || !ts8.isIdentifier(prop.name)) {
|
|
782
794
|
throw new Error(`Property in declaration tagged with "${LITERAL_AS_ENUM_TAG}" must be a property assignment with a static name`);
|
|
783
795
|
}
|
|
784
|
-
if (!
|
|
796
|
+
if (!ts8.isNumericLiteral(prop.initializer) && !ts8.isStringLiteralLike(prop.initializer)) {
|
|
785
797
|
throw new Error(`Property in declaration tagged with "${LITERAL_AS_ENUM_TAG}" must be initialized to a number or string literal`);
|
|
786
798
|
}
|
|
787
799
|
return {
|
|
@@ -797,7 +809,48 @@ function extractLiteralPropertiesAsEnumMembers(declaration) {
|
|
|
797
809
|
}
|
|
798
810
|
|
|
799
811
|
// packages/compiler-cli/src/ngtsc/docs/src/decorator_extractor.js
|
|
800
|
-
import
|
|
812
|
+
import ts10 from "typescript";
|
|
813
|
+
|
|
814
|
+
// packages/compiler-cli/src/ngtsc/docs/src/interface_extractor.js
|
|
815
|
+
import ts9 from "typescript";
|
|
816
|
+
var InterfaceExtractor = class extends PropertiesExtractor {
|
|
817
|
+
constructor(declaration, typeChecker) {
|
|
818
|
+
super(declaration, typeChecker);
|
|
819
|
+
}
|
|
820
|
+
/** Extract docs info specific to classes. */
|
|
821
|
+
extract() {
|
|
822
|
+
return {
|
|
823
|
+
name: this.declaration.name.text,
|
|
824
|
+
entryType: EntryType.Interface,
|
|
825
|
+
...super.extract(),
|
|
826
|
+
description: extractJsDocDescription(this.declaration),
|
|
827
|
+
jsdocTags: extractJsDocTags(this.declaration),
|
|
828
|
+
rawComment: extractRawJsDoc(this.declaration),
|
|
829
|
+
extends: this.extractInheritance(this.declaration),
|
|
830
|
+
implements: this.extractInterfaceConformance(this.declaration)
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
extractInheritance(declaration) {
|
|
834
|
+
if (!declaration.heritageClauses) {
|
|
835
|
+
return [];
|
|
836
|
+
}
|
|
837
|
+
for (const clause of declaration.heritageClauses) {
|
|
838
|
+
if (clause.token === ts9.SyntaxKind.ExtendsKeyword) {
|
|
839
|
+
const types = clause.types;
|
|
840
|
+
if (types.length > 0) {
|
|
841
|
+
return types.map((t) => t.getText());
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return [];
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
function extractInterface(declaration, typeChecker) {
|
|
849
|
+
const extractor = new InterfaceExtractor(declaration, typeChecker);
|
|
850
|
+
return extractor.extract();
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
// packages/compiler-cli/src/ngtsc/docs/src/decorator_extractor.js
|
|
801
854
|
function extractorDecorator(declaration, typeChecker) {
|
|
802
855
|
const documentedNode = getDecoratorJsDocNode(declaration, typeChecker);
|
|
803
856
|
const decoratorType = getDecoratorType(declaration);
|
|
@@ -808,7 +861,7 @@ function extractorDecorator(declaration, typeChecker) {
|
|
|
808
861
|
let signatures = [];
|
|
809
862
|
if (!members) {
|
|
810
863
|
const decoratorInterface = getDecoratorDeclaration(declaration, typeChecker);
|
|
811
|
-
const callSignatures = decoratorInterface.members.filter(
|
|
864
|
+
const callSignatures = decoratorInterface.members.filter(ts10.isCallSignatureDeclaration);
|
|
812
865
|
signatures = getDecoratorSignatures(callSignatures, typeChecker);
|
|
813
866
|
}
|
|
814
867
|
return {
|
|
@@ -826,7 +879,7 @@ function isDecoratorDeclaration(declaration) {
|
|
|
826
879
|
return !!getDecoratorType(declaration);
|
|
827
880
|
}
|
|
828
881
|
function isDecoratorOptionsInterface(declaration) {
|
|
829
|
-
return declaration.getSourceFile().statements.some((s) =>
|
|
882
|
+
return declaration.getSourceFile().statements.some((s) => ts10.isVariableStatement(s) && s.declarationList.declarations.some((d) => isDecoratorDeclaration(d) && d.name.getText() === declaration.name.getText()));
|
|
830
883
|
}
|
|
831
884
|
function getDecoratorType(declaration) {
|
|
832
885
|
const initializer = declaration.initializer?.getFullText() ?? "";
|
|
@@ -844,7 +897,7 @@ function getDecoratorDeclaration(declaration, typeChecker) {
|
|
|
844
897
|
const decoratorType = typeChecker.getTypeAtLocation(decoratorDeclaration);
|
|
845
898
|
const aliasDeclaration = decoratorType.getSymbol().getDeclarations()[0];
|
|
846
899
|
const decoratorInterface = aliasDeclaration;
|
|
847
|
-
if (!decoratorInterface || !
|
|
900
|
+
if (!decoratorInterface || !ts10.isInterfaceDeclaration(decoratorInterface)) {
|
|
848
901
|
throw new Error(`No decorator interface found for "${decoratorName}".`);
|
|
849
902
|
}
|
|
850
903
|
return decoratorInterface;
|
|
@@ -855,12 +908,12 @@ function getDecoratorProperties(declaration, typeChecker) {
|
|
|
855
908
|
const firstParamType = typeChecker.getTypeAtLocation(decoratorFirstParam);
|
|
856
909
|
let firstParamTypeDecl;
|
|
857
910
|
if (firstParamType.isUnion()) {
|
|
858
|
-
const firstParamTypeUnion = firstParamType.types.find((t) => (t.flags &
|
|
911
|
+
const firstParamTypeUnion = firstParamType.types.find((t) => (t.flags & ts10.TypeFlags.Undefined) === 0);
|
|
859
912
|
firstParamTypeDecl = firstParamTypeUnion?.getSymbol()?.getDeclarations()[0];
|
|
860
913
|
} else {
|
|
861
914
|
firstParamTypeDecl = firstParamType.getSymbol()?.getDeclarations()[0];
|
|
862
915
|
}
|
|
863
|
-
if (!firstParamTypeDecl || !
|
|
916
|
+
if (!firstParamTypeDecl || !ts10.isInterfaceDeclaration(firstParamTypeDecl)) {
|
|
864
917
|
return null;
|
|
865
918
|
}
|
|
866
919
|
const interfaceDeclaration = firstParamTypeDecl;
|
|
@@ -888,7 +941,7 @@ function getDecoratorInterface(declaration, typeChecker) {
|
|
|
888
941
|
const symbol = typeChecker.getSymbolAtLocation(declaration.name);
|
|
889
942
|
const decoratorType = typeChecker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
|
|
890
943
|
const decoratorInterface = decoratorType.getSymbol()?.getDeclarations()[0];
|
|
891
|
-
if (!decoratorInterface || !
|
|
944
|
+
if (!decoratorInterface || !ts10.isInterfaceDeclaration(decoratorInterface)) {
|
|
892
945
|
throw new Error(`No decorator interface found for "${name}".`);
|
|
893
946
|
}
|
|
894
947
|
return decoratorInterface;
|
|
@@ -897,22 +950,22 @@ function getDecoratorJsDocNode(declaration, typeChecker) {
|
|
|
897
950
|
const name = declaration.name.getText();
|
|
898
951
|
const decoratorInterface = getDecoratorInterface(declaration, typeChecker);
|
|
899
952
|
const callSignature = decoratorInterface.members.filter((node) => {
|
|
900
|
-
return
|
|
953
|
+
return ts10.isCallSignatureDeclaration(node) && extractRawJsDoc(node);
|
|
901
954
|
}).at(-1);
|
|
902
|
-
if (!callSignature || !
|
|
955
|
+
if (!callSignature || !ts10.isCallSignatureDeclaration(callSignature)) {
|
|
903
956
|
throw new Error(`No call signature with JsDoc on "${name}Decorator"`);
|
|
904
957
|
}
|
|
905
958
|
return callSignature;
|
|
906
959
|
}
|
|
907
960
|
function getParamTypeString(paramNode, typeChecker) {
|
|
908
961
|
const type = typeChecker.getTypeAtLocation(paramNode);
|
|
909
|
-
const printer =
|
|
962
|
+
const printer = ts10.createPrinter({ removeComments: true });
|
|
910
963
|
const sourceFile = paramNode.getSourceFile();
|
|
911
964
|
const replace = [];
|
|
912
965
|
if (type.isUnion()) {
|
|
913
966
|
for (const subType of type.types) {
|
|
914
967
|
const decl = subType.getSymbol()?.getDeclarations()?.[0];
|
|
915
|
-
if (decl &&
|
|
968
|
+
if (decl && ts10.isInterfaceDeclaration(decl) && decl.name.text !== "Function") {
|
|
916
969
|
replace.push({
|
|
917
970
|
initial: subType.symbol.name,
|
|
918
971
|
replacedWith: expandType(decl, sourceFile, printer)
|
|
@@ -920,19 +973,19 @@ function getParamTypeString(paramNode, typeChecker) {
|
|
|
920
973
|
}
|
|
921
974
|
}
|
|
922
975
|
}
|
|
923
|
-
let result = printer.printNode(
|
|
976
|
+
let result = printer.printNode(ts10.EmitHint.Unspecified, paramNode, sourceFile).replace(new RegExp(`${paramNode.name.getText()}\\??: `), "").replaceAll(/\s+/g, " ");
|
|
924
977
|
for (const { initial, replacedWith } of replace) {
|
|
925
978
|
result = result.replace(initial, replacedWith);
|
|
926
979
|
}
|
|
927
980
|
return result;
|
|
928
981
|
}
|
|
929
982
|
function expandType(decl, sourceFile, printer) {
|
|
930
|
-
const props = decl.members.map((member) => printer.printNode(
|
|
983
|
+
const props = decl.members.map((member) => printer.printNode(ts10.EmitHint.Unspecified, member, sourceFile)).join(" ").replaceAll(/\s+/g, " ");
|
|
931
984
|
return `{${props}}`;
|
|
932
985
|
}
|
|
933
986
|
|
|
934
987
|
// packages/compiler-cli/src/ngtsc/docs/src/enum_extractor.js
|
|
935
|
-
import
|
|
988
|
+
import ts11 from "typescript";
|
|
936
989
|
function extractEnum(declaration, typeChecker) {
|
|
937
990
|
return {
|
|
938
991
|
name: declaration.name.getText(),
|
|
@@ -956,36 +1009,36 @@ function extractEnumMembers(declaration, checker) {
|
|
|
956
1009
|
}
|
|
957
1010
|
function getEnumMemberValue(memberNode) {
|
|
958
1011
|
const literal = memberNode.getChildren().find((n) => {
|
|
959
|
-
return
|
|
1012
|
+
return ts11.isNumericLiteral(n) || ts11.isStringLiteral(n) || ts11.isPrefixUnaryExpression(n) && n.operator === ts11.SyntaxKind.MinusToken && ts11.isNumericLiteral(n.operand);
|
|
960
1013
|
});
|
|
961
1014
|
return literal?.getText() ?? "";
|
|
962
1015
|
}
|
|
963
1016
|
|
|
964
1017
|
// packages/compiler-cli/src/ngtsc/docs/src/initializer_api_function_extractor.js
|
|
965
|
-
import
|
|
1018
|
+
import ts12 from "typescript";
|
|
966
1019
|
var initializerApiTag = "initializerApiFunction";
|
|
967
1020
|
function isInitializerApiFunction(node, typeChecker) {
|
|
968
|
-
if (
|
|
1021
|
+
if (ts12.isFunctionDeclaration(node) && node.name !== void 0 && node.body === void 0) {
|
|
969
1022
|
const implementation = findImplementationOfFunction(node, typeChecker);
|
|
970
1023
|
if (implementation !== void 0) {
|
|
971
1024
|
node = implementation;
|
|
972
1025
|
}
|
|
973
1026
|
}
|
|
974
|
-
if (!
|
|
1027
|
+
if (!ts12.isFunctionDeclaration(node) && !ts12.isVariableDeclaration(node)) {
|
|
975
1028
|
return false;
|
|
976
1029
|
}
|
|
977
|
-
let tagContainer =
|
|
1030
|
+
let tagContainer = ts12.isFunctionDeclaration(node) ? node : getContainerVariableStatement(node);
|
|
978
1031
|
if (tagContainer === null) {
|
|
979
1032
|
return false;
|
|
980
1033
|
}
|
|
981
|
-
const tags =
|
|
1034
|
+
const tags = ts12.getJSDocTags(tagContainer);
|
|
982
1035
|
return tags.some((t) => t.tagName.text === initializerApiTag);
|
|
983
1036
|
}
|
|
984
1037
|
function extractInitializerApiFunction(node, typeChecker) {
|
|
985
|
-
if (node.name === void 0 || !
|
|
1038
|
+
if (node.name === void 0 || !ts12.isIdentifier(node.name)) {
|
|
986
1039
|
throw new Error(`Initializer API: Expected literal variable name.`);
|
|
987
1040
|
}
|
|
988
|
-
const container =
|
|
1041
|
+
const container = ts12.isFunctionDeclaration(node) ? node : getContainerVariableStatement(node);
|
|
989
1042
|
if (container === null) {
|
|
990
1043
|
throw new Error("Initializer API: Could not find container AST node of variable.");
|
|
991
1044
|
}
|
|
@@ -996,7 +1049,7 @@ function extractInitializerApiFunction(node, typeChecker) {
|
|
|
996
1049
|
for (const property of type.getProperties()) {
|
|
997
1050
|
const subName = property.getName();
|
|
998
1051
|
const subDecl = property.getDeclarations()?.[0];
|
|
999
|
-
if (subDecl === void 0 || !
|
|
1052
|
+
if (subDecl === void 0 || !ts12.isPropertySignature(subDecl)) {
|
|
1000
1053
|
throw new Error(`Initializer API: Could not resolve declaration of sub-property: ${name}.${subName}`);
|
|
1001
1054
|
}
|
|
1002
1055
|
const subType = typeChecker.getTypeAtLocation(subDecl);
|
|
@@ -1005,7 +1058,7 @@ function extractInitializerApiFunction(node, typeChecker) {
|
|
|
1005
1058
|
let jsdocTags;
|
|
1006
1059
|
let description;
|
|
1007
1060
|
let rawComment;
|
|
1008
|
-
if (
|
|
1061
|
+
if (ts12.isFunctionDeclaration(node)) {
|
|
1009
1062
|
const implementation = findImplementationOfFunction(node, typeChecker);
|
|
1010
1063
|
if (implementation === void 0) {
|
|
1011
1064
|
throw new Error(`Initializer API: Could not find implementation of function: ${name}`);
|
|
@@ -1053,10 +1106,10 @@ function extractInitializerApiFunction(node, typeChecker) {
|
|
|
1053
1106
|
};
|
|
1054
1107
|
}
|
|
1055
1108
|
function getContainerVariableStatement(node) {
|
|
1056
|
-
if (!
|
|
1109
|
+
if (!ts12.isVariableDeclarationList(node.parent)) {
|
|
1057
1110
|
return null;
|
|
1058
1111
|
}
|
|
1059
|
-
if (!
|
|
1112
|
+
if (!ts12.isVariableStatement(node.parent.parent)) {
|
|
1060
1113
|
return null;
|
|
1061
1114
|
}
|
|
1062
1115
|
return node.parent.parent;
|
|
@@ -1084,15 +1137,15 @@ function extractTypeAlias(declaration) {
|
|
|
1084
1137
|
}
|
|
1085
1138
|
|
|
1086
1139
|
// packages/compiler-cli/src/ngtsc/docs/src/import_extractor.js
|
|
1087
|
-
import
|
|
1140
|
+
import ts13 from "typescript";
|
|
1088
1141
|
function getImportedSymbols(sourceFile) {
|
|
1089
1142
|
const importSpecifiers = /* @__PURE__ */ new Map();
|
|
1090
1143
|
function visit(node) {
|
|
1091
|
-
if (
|
|
1144
|
+
if (ts13.isImportDeclaration(node)) {
|
|
1092
1145
|
let moduleSpecifier = node.moduleSpecifier.getText(sourceFile).replace(/['"]/g, "");
|
|
1093
1146
|
if (moduleSpecifier.startsWith("@angular/")) {
|
|
1094
1147
|
const namedBindings = node.importClause?.namedBindings;
|
|
1095
|
-
if (namedBindings &&
|
|
1148
|
+
if (namedBindings && ts13.isNamedImports(namedBindings)) {
|
|
1096
1149
|
namedBindings.elements.forEach((importSpecifier) => {
|
|
1097
1150
|
const importName = importSpecifier.name.text;
|
|
1098
1151
|
const importAlias = importSpecifier.propertyName ? importSpecifier.propertyName.text : void 0;
|
|
@@ -1101,7 +1154,7 @@ function getImportedSymbols(sourceFile) {
|
|
|
1101
1154
|
}
|
|
1102
1155
|
}
|
|
1103
1156
|
}
|
|
1104
|
-
|
|
1157
|
+
ts13.forEachChild(node, visit);
|
|
1105
1158
|
}
|
|
1106
1159
|
visit(sourceFile);
|
|
1107
1160
|
return importSpecifiers;
|
|
@@ -1145,8 +1198,8 @@ var DocsExtractor = class {
|
|
|
1145
1198
|
entry.source = {
|
|
1146
1199
|
filePath: getRelativeFilePath(realSourceFile, rootDir),
|
|
1147
1200
|
// Start & End are off by 1
|
|
1148
|
-
startLine:
|
|
1149
|
-
endLine:
|
|
1201
|
+
startLine: ts14.getLineAndCharacterOfPosition(realSourceFile, node.getStart()).line + 1,
|
|
1202
|
+
endLine: ts14.getLineAndCharacterOfPosition(realSourceFile, node.getEnd()).line + 1
|
|
1150
1203
|
};
|
|
1151
1204
|
entries.push({ ...entry, name: exportName });
|
|
1152
1205
|
}
|
|
@@ -1161,20 +1214,20 @@ var DocsExtractor = class {
|
|
|
1161
1214
|
if (isInitializerApiFunction(node, this.typeChecker)) {
|
|
1162
1215
|
return extractInitializerApiFunction(node, this.typeChecker);
|
|
1163
1216
|
}
|
|
1164
|
-
if (
|
|
1217
|
+
if (ts14.isInterfaceDeclaration(node) && !isIgnoredInterface(node)) {
|
|
1165
1218
|
return extractInterface(node, this.typeChecker);
|
|
1166
1219
|
}
|
|
1167
|
-
if (
|
|
1220
|
+
if (ts14.isFunctionDeclaration(node)) {
|
|
1168
1221
|
const functionExtractor = new FunctionExtractor(node.name.getText(), node, this.typeChecker);
|
|
1169
1222
|
return functionExtractor.extract();
|
|
1170
1223
|
}
|
|
1171
|
-
if (
|
|
1224
|
+
if (ts14.isVariableDeclaration(node) && !isSyntheticAngularConstant(node)) {
|
|
1172
1225
|
return isDecoratorDeclaration(node) ? extractorDecorator(node, this.typeChecker) : extractConstant(node, this.typeChecker);
|
|
1173
1226
|
}
|
|
1174
|
-
if (
|
|
1227
|
+
if (ts14.isTypeAliasDeclaration(node)) {
|
|
1175
1228
|
return extractTypeAlias(node);
|
|
1176
1229
|
}
|
|
1177
|
-
if (
|
|
1230
|
+
if (ts14.isEnumDeclaration(node)) {
|
|
1178
1231
|
return extractEnum(node, this.typeChecker);
|
|
1179
1232
|
}
|
|
1180
1233
|
return null;
|
|
@@ -1205,7 +1258,7 @@ function getRelativeFilePath(sourceFile, rootDir) {
|
|
|
1205
1258
|
|
|
1206
1259
|
// packages/compiler-cli/src/ngtsc/program.js
|
|
1207
1260
|
import { HtmlParser, MessageBundle } from "@angular/compiler";
|
|
1208
|
-
import
|
|
1261
|
+
import ts30 from "typescript";
|
|
1209
1262
|
|
|
1210
1263
|
// packages/compiler-cli/src/transformers/i18n.js
|
|
1211
1264
|
import { Xliff, Xliff2, Xmb } from "@angular/compiler";
|
|
@@ -1259,7 +1312,7 @@ function getPathNormalizer(basePath) {
|
|
|
1259
1312
|
}
|
|
1260
1313
|
|
|
1261
1314
|
// packages/compiler-cli/src/typescript_support.js
|
|
1262
|
-
import
|
|
1315
|
+
import ts15 from "typescript";
|
|
1263
1316
|
|
|
1264
1317
|
// packages/compiler-cli/src/version_helpers.js
|
|
1265
1318
|
function toNumbers(value) {
|
|
@@ -1299,7 +1352,7 @@ function compareVersions(v1, v2) {
|
|
|
1299
1352
|
// packages/compiler-cli/src/typescript_support.js
|
|
1300
1353
|
var MIN_TS_VERSION = "5.9.0";
|
|
1301
1354
|
var MAX_TS_VERSION = "6.0.0";
|
|
1302
|
-
var tsVersion =
|
|
1355
|
+
var tsVersion = ts15.version;
|
|
1303
1356
|
function checkVersion(version, minVersion, maxVersion) {
|
|
1304
1357
|
if (compareVersions(version, minVersion) < 0 || compareVersions(version, maxVersion) >= 0) {
|
|
1305
1358
|
throw new Error(`The Angular Compiler requires TypeScript >=${minVersion} and <${maxVersion} but ${version} was found instead.`);
|
|
@@ -1310,7 +1363,7 @@ function verifySupportedTypeScriptVersion() {
|
|
|
1310
1363
|
}
|
|
1311
1364
|
|
|
1312
1365
|
// packages/compiler-cli/src/ngtsc/core/src/compiler.js
|
|
1313
|
-
import
|
|
1366
|
+
import ts28 from "typescript";
|
|
1314
1367
|
|
|
1315
1368
|
// packages/compiler-cli/src/ngtsc/cycles/src/analyzer.js
|
|
1316
1369
|
var CycleAnalyzer = class {
|
|
@@ -1419,7 +1472,7 @@ var Cycle = class {
|
|
|
1419
1472
|
};
|
|
1420
1473
|
|
|
1421
1474
|
// packages/compiler-cli/src/ngtsc/cycles/src/imports.js
|
|
1422
|
-
import
|
|
1475
|
+
import ts16 from "typescript";
|
|
1423
1476
|
var ImportGraph = class {
|
|
1424
1477
|
checker;
|
|
1425
1478
|
perf;
|
|
@@ -1485,10 +1538,10 @@ var ImportGraph = class {
|
|
|
1485
1538
|
return this.perf.inPhase(PerfPhase.CycleDetection, () => {
|
|
1486
1539
|
const imports = /* @__PURE__ */ new Set();
|
|
1487
1540
|
for (const stmt of sf.statements) {
|
|
1488
|
-
if (!
|
|
1541
|
+
if (!ts16.isImportDeclaration(stmt) && !ts16.isExportDeclaration(stmt) || stmt.moduleSpecifier === void 0) {
|
|
1489
1542
|
continue;
|
|
1490
1543
|
}
|
|
1491
|
-
if (
|
|
1544
|
+
if (ts16.isImportDeclaration(stmt) && stmt.importClause !== void 0 && isTypeOnlyImportClause(stmt.importClause)) {
|
|
1492
1545
|
continue;
|
|
1493
1546
|
}
|
|
1494
1547
|
const symbol = this.checker.getSymbolAtLocation(stmt.moduleSpecifier);
|
|
@@ -1496,7 +1549,7 @@ var ImportGraph = class {
|
|
|
1496
1549
|
continue;
|
|
1497
1550
|
}
|
|
1498
1551
|
const moduleFile = symbol.valueDeclaration;
|
|
1499
|
-
if (
|
|
1552
|
+
if (ts16.isSourceFile(moduleFile) && isLocalFile(moduleFile)) {
|
|
1500
1553
|
imports.add(moduleFile);
|
|
1501
1554
|
}
|
|
1502
1555
|
}
|
|
@@ -1511,7 +1564,7 @@ function isTypeOnlyImportClause(node) {
|
|
|
1511
1564
|
if (node.isTypeOnly) {
|
|
1512
1565
|
return true;
|
|
1513
1566
|
}
|
|
1514
|
-
if (node.namedBindings !== void 0 &&
|
|
1567
|
+
if (node.namedBindings !== void 0 && ts16.isNamedImports(node.namedBindings) && node.namedBindings.elements.every((specifier) => specifier.isTypeOnly)) {
|
|
1515
1568
|
return true;
|
|
1516
1569
|
}
|
|
1517
1570
|
return false;
|
|
@@ -1539,7 +1592,7 @@ var Found = class {
|
|
|
1539
1592
|
};
|
|
1540
1593
|
|
|
1541
1594
|
// packages/compiler-cli/src/ngtsc/entry_point/src/generator.js
|
|
1542
|
-
import
|
|
1595
|
+
import ts17 from "typescript";
|
|
1543
1596
|
var FlatIndexGenerator = class {
|
|
1544
1597
|
entryPoint;
|
|
1545
1598
|
moduleName;
|
|
@@ -1558,7 +1611,7 @@ var FlatIndexGenerator = class {
|
|
|
1558
1611
|
|
|
1559
1612
|
export * from '${relativeEntryPoint}';
|
|
1560
1613
|
`;
|
|
1561
|
-
const genFile =
|
|
1614
|
+
const genFile = ts17.createSourceFile(this.flatIndexPath, contents, ts17.ScriptTarget.ES2015, true, ts17.ScriptKind.TS);
|
|
1562
1615
|
if (this.moduleName !== null) {
|
|
1563
1616
|
genFile.moduleName = this.moduleName;
|
|
1564
1617
|
}
|
|
@@ -1583,7 +1636,7 @@ function findFlatIndexEntryPoint(rootFiles) {
|
|
|
1583
1636
|
}
|
|
1584
1637
|
|
|
1585
1638
|
// packages/compiler-cli/src/ngtsc/entry_point/src/private_export_checker.js
|
|
1586
|
-
import
|
|
1639
|
+
import ts18 from "typescript";
|
|
1587
1640
|
function checkForPrivateExports(entryPoint, checker, refGraph) {
|
|
1588
1641
|
const diagnostics = [];
|
|
1589
1642
|
const topLevelExports = /* @__PURE__ */ new Set();
|
|
@@ -1593,7 +1646,7 @@ function checkForPrivateExports(entryPoint, checker, refGraph) {
|
|
|
1593
1646
|
}
|
|
1594
1647
|
const exportedSymbols = checker.getExportsOfModule(moduleSymbol);
|
|
1595
1648
|
exportedSymbols.forEach((symbol) => {
|
|
1596
|
-
if (symbol.flags &
|
|
1649
|
+
if (symbol.flags & ts18.SymbolFlags.Alias) {
|
|
1597
1650
|
symbol = checker.getAliasedSymbol(symbol);
|
|
1598
1651
|
}
|
|
1599
1652
|
const decl = symbol.valueDeclaration;
|
|
@@ -1617,7 +1670,7 @@ function checkForPrivateExports(entryPoint, checker, refGraph) {
|
|
|
1617
1670
|
visibleVia = transitivePath.map((seg) => getNameOfDeclaration(seg)).join(" -> ");
|
|
1618
1671
|
}
|
|
1619
1672
|
const diagnostic = {
|
|
1620
|
-
category:
|
|
1673
|
+
category: ts18.DiagnosticCategory.Error,
|
|
1621
1674
|
code: ngErrorCode(ErrorCode.SYMBOL_NOT_EXPORTED),
|
|
1622
1675
|
file: transitiveReference.getSourceFile(),
|
|
1623
1676
|
...getPosOfDeclaration(transitiveReference),
|
|
@@ -1637,7 +1690,7 @@ function getPosOfDeclaration(decl) {
|
|
|
1637
1690
|
};
|
|
1638
1691
|
}
|
|
1639
1692
|
function getIdentifierOfDeclaration(decl) {
|
|
1640
|
-
if ((
|
|
1693
|
+
if ((ts18.isClassDeclaration(decl) || ts18.isVariableDeclaration(decl) || ts18.isFunctionDeclaration(decl)) && decl.name !== void 0 && ts18.isIdentifier(decl.name)) {
|
|
1641
1694
|
return decl.name;
|
|
1642
1695
|
} else {
|
|
1643
1696
|
return null;
|
|
@@ -1649,13 +1702,13 @@ function getNameOfDeclaration(decl) {
|
|
|
1649
1702
|
}
|
|
1650
1703
|
function getDescriptorOfDeclaration(decl) {
|
|
1651
1704
|
switch (decl.kind) {
|
|
1652
|
-
case
|
|
1705
|
+
case ts18.SyntaxKind.ClassDeclaration:
|
|
1653
1706
|
return "class";
|
|
1654
|
-
case
|
|
1707
|
+
case ts18.SyntaxKind.FunctionDeclaration:
|
|
1655
1708
|
return "function";
|
|
1656
|
-
case
|
|
1709
|
+
case ts18.SyntaxKind.VariableDeclaration:
|
|
1657
1710
|
return "variable";
|
|
1658
|
-
case
|
|
1711
|
+
case ts18.SyntaxKind.EnumDeclaration:
|
|
1659
1712
|
return "enum";
|
|
1660
1713
|
default:
|
|
1661
1714
|
return "declaration";
|
|
@@ -2495,7 +2548,7 @@ var NgModuleIndexImpl = class {
|
|
|
2495
2548
|
};
|
|
2496
2549
|
|
|
2497
2550
|
// packages/compiler-cli/src/ngtsc/resource/src/loader.js
|
|
2498
|
-
import
|
|
2551
|
+
import ts19 from "typescript";
|
|
2499
2552
|
var CSS_PREPROCESSOR_EXT = /(\.scss|\.sass|\.less|\.styl)$/;
|
|
2500
2553
|
var RESOURCE_MARKER = ".$ngresource$";
|
|
2501
2554
|
var RESOURCE_MARKER_TS = RESOURCE_MARKER + ".ts";
|
|
@@ -2671,7 +2724,7 @@ var AdapterResourceLoader = class {
|
|
|
2671
2724
|
* for the file by setting up a module resolution for it that will fail.
|
|
2672
2725
|
*/
|
|
2673
2726
|
getResolvedCandidateLocations(url, fromFile) {
|
|
2674
|
-
const failedLookup =
|
|
2727
|
+
const failedLookup = ts19.resolveModuleName(url + RESOURCE_MARKER, fromFile, this.options, this.lookupResolutionHost);
|
|
2675
2728
|
if (failedLookup.failedLookupLocations === void 0) {
|
|
2676
2729
|
throw new Error(`Internal error: expected to find failedLookupLocations during resolution of resource '${url}' in context of ${fromFile}`);
|
|
2677
2730
|
}
|
|
@@ -2804,10 +2857,10 @@ var StandaloneComponentScopeReader = class {
|
|
|
2804
2857
|
};
|
|
2805
2858
|
|
|
2806
2859
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/interpolated_signal_not_invoked/index.js
|
|
2807
|
-
import { ASTWithSource as ASTWithSource2, BindingType, Interpolation, PrefixNot, PropertyRead as PropertyRead2, TmplAstBoundAttribute, TmplAstIfBlock, TmplAstSwitchBlock } from "@angular/compiler";
|
|
2860
|
+
import { ASTWithSource as ASTWithSource2, BindingType, Interpolation, PrefixNot, PropertyRead as PropertyRead2, TmplAstBoundAttribute, TmplAstElement as TmplAstElement2, TmplAstIfBlock, TmplAstSwitchBlock, TmplAstTemplate as TmplAstTemplate2 } from "@angular/compiler";
|
|
2808
2861
|
|
|
2809
2862
|
// packages/compiler-cli/src/ngtsc/typecheck/src/symbol_util.js
|
|
2810
|
-
import
|
|
2863
|
+
import ts20 from "typescript";
|
|
2811
2864
|
var SIGNAL_FNS = /* @__PURE__ */ new Set([
|
|
2812
2865
|
"WritableSignal",
|
|
2813
2866
|
"Signal",
|
|
@@ -2824,23 +2877,13 @@ function isSignalSymbol(symbol) {
|
|
|
2824
2877
|
const declarations = symbol.getDeclarations();
|
|
2825
2878
|
return declarations !== void 0 && declarations.some((decl) => {
|
|
2826
2879
|
const fileName = decl.getSourceFile().fileName;
|
|
2827
|
-
return (
|
|
2880
|
+
return (ts20.isInterfaceDeclaration(decl) || ts20.isTypeAliasDeclaration(decl)) && SIGNAL_FNS.has(decl.name.text) && (fileName.includes("@angular/core") || fileName.includes("angular2/rc/packages/core") || fileName.includes("bin/packages/core"));
|
|
2828
2881
|
});
|
|
2829
2882
|
}
|
|
2830
2883
|
|
|
2831
2884
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/api/api.js
|
|
2832
2885
|
import { CombinedRecursiveAstVisitor as CombinedRecursiveAstVisitor2 } from "@angular/compiler";
|
|
2833
2886
|
var TemplateCheckWithVisitor = class {
|
|
2834
|
-
/**
|
|
2835
|
-
* When extended diagnostics were first introduced, the visitor wasn't implemented correctly
|
|
2836
|
-
* which meant that it wasn't visiting the `templateAttrs` of structural directives (e.g.
|
|
2837
|
-
* the expression of `*ngIf`). Fixing the issue causes a lot of internal breakages and will likely
|
|
2838
|
-
* need to be done in a major version to avoid external breakages. This flag is used to opt out
|
|
2839
|
-
* pre-existing diagnostics from the correct behavior until the breakages have been fixed while
|
|
2840
|
-
* ensuring that newly-written diagnostics are correct from the beginning.
|
|
2841
|
-
* TODO(crisbeto): remove this flag and fix the internal brekages.
|
|
2842
|
-
*/
|
|
2843
|
-
canVisitStructuralAttributes = true;
|
|
2844
2887
|
/**
|
|
2845
2888
|
* Base implementation for run function, visits all nodes in template and calls
|
|
2846
2889
|
* `visitNode()` for each one.
|
|
@@ -2873,9 +2916,7 @@ var TemplateVisitor2 = class extends CombinedRecursiveAstVisitor2 {
|
|
|
2873
2916
|
this.visitAllTemplateNodes(template.outputs);
|
|
2874
2917
|
}
|
|
2875
2918
|
this.visitAllTemplateNodes(template.directives);
|
|
2876
|
-
|
|
2877
|
-
this.visitAllTemplateNodes(template.templateAttrs);
|
|
2878
|
-
}
|
|
2919
|
+
this.visitAllTemplateNodes(template.templateAttrs);
|
|
2879
2920
|
this.visitAllTemplateNodes(template.variables);
|
|
2880
2921
|
this.visitAllTemplateNodes(template.references);
|
|
2881
2922
|
this.visitAllTemplateNodes(template.children);
|
|
@@ -2895,23 +2936,21 @@ var InterpolatedSignalCheck = class extends TemplateCheckWithVisitor {
|
|
|
2895
2936
|
visitNode(ctx, component, node) {
|
|
2896
2937
|
if (node instanceof Interpolation) {
|
|
2897
2938
|
return node.expressions.map((item) => item instanceof PrefixNot ? item.expression : item).filter((item) => item instanceof PropertyRead2).flatMap((item) => buildDiagnosticForSignal(ctx, item, component));
|
|
2898
|
-
} else if (node instanceof
|
|
2899
|
-
const
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
const
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
)
|
|
2913
|
-
return buildDiagnosticForSignal(ctx, nodeAst, component);
|
|
2914
|
-
}
|
|
2939
|
+
} else if (node instanceof TmplAstElement2 && node.inputs.length > 0) {
|
|
2940
|
+
const directivesOfElement = ctx.templateTypeChecker.getDirectivesOfNode(component, node);
|
|
2941
|
+
return node.inputs.flatMap((input) => checkBoundAttribute(ctx, component, directivesOfElement, input));
|
|
2942
|
+
} else if (node instanceof TmplAstTemplate2 && node.tagName === "ng-template") {
|
|
2943
|
+
const directivesOfElement = ctx.templateTypeChecker.getDirectivesOfNode(component, node);
|
|
2944
|
+
const inputDiagnostics = node.inputs.flatMap((input) => {
|
|
2945
|
+
return checkBoundAttribute(ctx, component, directivesOfElement, input);
|
|
2946
|
+
});
|
|
2947
|
+
const templateAttrDiagnostics = node.templateAttrs.flatMap((attr) => {
|
|
2948
|
+
if (!(attr instanceof TmplAstBoundAttribute)) {
|
|
2949
|
+
return [];
|
|
2950
|
+
}
|
|
2951
|
+
return checkBoundAttribute(ctx, component, directivesOfElement, attr);
|
|
2952
|
+
});
|
|
2953
|
+
return inputDiagnostics.concat(templateAttrDiagnostics);
|
|
2915
2954
|
} else if (node instanceof TmplAstIfBlock) {
|
|
2916
2955
|
return node.branches.map((branch) => branch.expression).filter((expr) => expr instanceof ASTWithSource2).map((expr) => {
|
|
2917
2956
|
const ast = expr.ast;
|
|
@@ -2926,6 +2965,24 @@ var InterpolatedSignalCheck = class extends TemplateCheckWithVisitor {
|
|
|
2926
2965
|
return [];
|
|
2927
2966
|
}
|
|
2928
2967
|
};
|
|
2968
|
+
function checkBoundAttribute(ctx, component, directivesOfElement, node) {
|
|
2969
|
+
if (directivesOfElement !== null && directivesOfElement.some((dir) => dir.inputs.getByBindingPropertyName(node.name) !== null)) {
|
|
2970
|
+
return [];
|
|
2971
|
+
}
|
|
2972
|
+
const nodeAst = isPropertyReadNodeAst(node);
|
|
2973
|
+
if (
|
|
2974
|
+
// a bound property like `[prop]="mySignal"`
|
|
2975
|
+
(node.type === BindingType.Property || // or a class binding like `[class.myClass]="mySignal"`
|
|
2976
|
+
node.type === BindingType.Class || // or a style binding like `[style.width]="mySignal"`
|
|
2977
|
+
node.type === BindingType.Style || // or an attribute binding like `[attr.role]="mySignal"`
|
|
2978
|
+
node.type === BindingType.Attribute || // or an animation binding like `[animate.enter]="mySignal"`
|
|
2979
|
+
node.type === BindingType.Animation || // or an animation binding like `[@myAnimation]="mySignal"`
|
|
2980
|
+
node.type === BindingType.LegacyAnimation) && nodeAst
|
|
2981
|
+
) {
|
|
2982
|
+
return buildDiagnosticForSignal(ctx, nodeAst, component);
|
|
2983
|
+
}
|
|
2984
|
+
return [];
|
|
2985
|
+
}
|
|
2929
2986
|
function isPropertyReadNodeAst(node) {
|
|
2930
2987
|
if (node.value instanceof ASTWithSource2 === false) {
|
|
2931
2988
|
return void 0;
|
|
@@ -2952,8 +3009,11 @@ function buildDiagnosticForSignal(ctx, node, component) {
|
|
|
2952
3009
|
const diagnostic = ctx.makeTemplateDiagnostic(templateMapping.span, errorString);
|
|
2953
3010
|
return [diagnostic];
|
|
2954
3011
|
}
|
|
3012
|
+
if (!isFunctionInstanceProperty(node.name) && !isSignalInstanceProperty(node.name)) {
|
|
3013
|
+
return [];
|
|
3014
|
+
}
|
|
2955
3015
|
const symbolOfReceiver = ctx.templateTypeChecker.getSymbolOfNode(node.receiver, component);
|
|
2956
|
-
if (
|
|
3016
|
+
if (symbolOfReceiver !== null && symbolOfReceiver.kind === SymbolKind.Expression && isSignalReference(symbolOfReceiver)) {
|
|
2957
3017
|
const templateMapping = ctx.templateTypeChecker.getSourceMappingAtTcbLocation(symbolOfReceiver.tcbLocation);
|
|
2958
3018
|
const errorString = `${node.receiver.name} is a function and should be invoked: ${node.receiver.name}()`;
|
|
2959
3019
|
const diagnostic = ctx.makeTemplateDiagnostic(templateMapping.span, errorString);
|
|
@@ -2991,7 +3051,7 @@ var factory2 = {
|
|
|
2991
3051
|
};
|
|
2992
3052
|
|
|
2993
3053
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_control_flow_directive/index.js
|
|
2994
|
-
import { TmplAstTemplate as
|
|
3054
|
+
import { TmplAstTemplate as TmplAstTemplate3 } from "@angular/compiler";
|
|
2995
3055
|
var KNOWN_CONTROL_FLOW_DIRECTIVES = /* @__PURE__ */ new Map([
|
|
2996
3056
|
["ngIf", { directive: "NgIf", builtIn: "@if" }],
|
|
2997
3057
|
["ngFor", { directive: "NgFor", builtIn: "@for" }],
|
|
@@ -3008,7 +3068,7 @@ var MissingControlFlowDirectiveCheck = class extends TemplateCheckWithVisitor {
|
|
|
3008
3068
|
return super.run(ctx, component, template);
|
|
3009
3069
|
}
|
|
3010
3070
|
visitNode(ctx, component, node) {
|
|
3011
|
-
if (!(node instanceof
|
|
3071
|
+
if (!(node instanceof TmplAstTemplate3))
|
|
3012
3072
|
return [];
|
|
3013
3073
|
const controlFlowAttr = node.templateAttrs.find((attr) => KNOWN_CONTROL_FLOW_DIRECTIVES.has(attr.name));
|
|
3014
3074
|
if (!controlFlowAttr)
|
|
@@ -3033,12 +3093,12 @@ var factory3 = {
|
|
|
3033
3093
|
};
|
|
3034
3094
|
|
|
3035
3095
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_ngforof_let/index.js
|
|
3036
|
-
import { TmplAstTemplate as
|
|
3096
|
+
import { TmplAstTemplate as TmplAstTemplate4 } from "@angular/compiler";
|
|
3037
3097
|
var MissingNgForOfLetCheck = class extends TemplateCheckWithVisitor {
|
|
3038
3098
|
code = ErrorCode.MISSING_NGFOROF_LET;
|
|
3039
3099
|
visitNode(ctx, component, node) {
|
|
3040
|
-
const isTemplate = node instanceof
|
|
3041
|
-
if (!(node instanceof
|
|
3100
|
+
const isTemplate = node instanceof TmplAstTemplate4;
|
|
3101
|
+
if (!(node instanceof TmplAstTemplate4)) {
|
|
3042
3102
|
return [];
|
|
3043
3103
|
}
|
|
3044
3104
|
if (node.templateAttrs.length === 0) {
|
|
@@ -3063,14 +3123,16 @@ var factory4 = {
|
|
|
3063
3123
|
};
|
|
3064
3124
|
|
|
3065
3125
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_structural_directive/index.js
|
|
3066
|
-
import { TmplAstTemplate as
|
|
3126
|
+
import { TmplAstTemplate as TmplAstTemplate5 } from "@angular/compiler";
|
|
3067
3127
|
var KNOWN_CONTROL_FLOW_DIRECTIVES2 = /* @__PURE__ */ new Set([
|
|
3068
3128
|
"ngIf",
|
|
3069
3129
|
"ngFor",
|
|
3070
3130
|
"ngForOf",
|
|
3071
3131
|
"ngForTrackBy",
|
|
3072
3132
|
"ngSwitchCase",
|
|
3073
|
-
"ngSwitchDefault"
|
|
3133
|
+
"ngSwitchDefault",
|
|
3134
|
+
"ngIfThen",
|
|
3135
|
+
"ngIfElse"
|
|
3074
3136
|
]);
|
|
3075
3137
|
var MissingStructuralDirectiveCheck = class extends TemplateCheckWithVisitor {
|
|
3076
3138
|
code = ErrorCode.MISSING_STRUCTURAL_DIRECTIVE;
|
|
@@ -3082,15 +3144,15 @@ var MissingStructuralDirectiveCheck = class extends TemplateCheckWithVisitor {
|
|
|
3082
3144
|
return super.run(ctx, component, template);
|
|
3083
3145
|
}
|
|
3084
3146
|
visitNode(ctx, component, node) {
|
|
3085
|
-
if (!(node instanceof
|
|
3147
|
+
if (!(node instanceof TmplAstTemplate5))
|
|
3086
3148
|
return [];
|
|
3087
3149
|
const customStructuralDirective = node.templateAttrs.find((attr) => !KNOWN_CONTROL_FLOW_DIRECTIVES2.has(attr.name));
|
|
3088
3150
|
if (!customStructuralDirective)
|
|
3089
3151
|
return [];
|
|
3090
3152
|
const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
|
|
3091
|
-
|
|
3153
|
+
const hasStructuralDirective = symbol?.directives.some((dir) => dir.selector?.includes(`[${customStructuralDirective.name}]`));
|
|
3154
|
+
if (hasStructuralDirective)
|
|
3092
3155
|
return [];
|
|
3093
|
-
}
|
|
3094
3156
|
const sourceSpan = customStructuralDirective.keySpan || customStructuralDirective.sourceSpan;
|
|
3095
3157
|
const errorMessage = `A structural directive \`${customStructuralDirective.name}\` was used in the template without a corresponding import in the component. Make sure that the directive is included in the \`@Component.imports\` array of this component.`;
|
|
3096
3158
|
return [ctx.makeTemplateDiagnostic(sourceSpan, errorMessage)];
|
|
@@ -3104,9 +3166,8 @@ var factory5 = {
|
|
|
3104
3166
|
|
|
3105
3167
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable/index.js
|
|
3106
3168
|
import { Binary } from "@angular/compiler";
|
|
3107
|
-
import
|
|
3169
|
+
import ts21 from "typescript";
|
|
3108
3170
|
var NullishCoalescingNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
3109
|
-
canVisitStructuralAttributes = false;
|
|
3110
3171
|
code = ErrorCode.NULLISH_COALESCING_NOT_NULLABLE;
|
|
3111
3172
|
visitNode(ctx, component, node) {
|
|
3112
3173
|
if (!(node instanceof Binary) || node.operation !== "??")
|
|
@@ -3116,7 +3177,7 @@ var NullishCoalescingNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
|
3116
3177
|
return [];
|
|
3117
3178
|
}
|
|
3118
3179
|
const typeLeft = symbolLeft.tsType;
|
|
3119
|
-
if (typeLeft.flags & (
|
|
3180
|
+
if (typeLeft.flags & (ts21.TypeFlags.Any | ts21.TypeFlags.Unknown)) {
|
|
3120
3181
|
return [];
|
|
3121
3182
|
}
|
|
3122
3183
|
if (typeLeft.getNonNullableType() !== typeLeft)
|
|
@@ -3147,10 +3208,9 @@ var factory6 = {
|
|
|
3147
3208
|
|
|
3148
3209
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/optional_chain_not_nullable/index.js
|
|
3149
3210
|
import { KeyedRead, SafeCall, SafeKeyedRead, SafePropertyRead } from "@angular/compiler";
|
|
3150
|
-
import
|
|
3211
|
+
import ts22 from "typescript";
|
|
3151
3212
|
var OptionalChainNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
3152
3213
|
noUncheckedIndexedAccess;
|
|
3153
|
-
canVisitStructuralAttributes = false;
|
|
3154
3214
|
code = ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE;
|
|
3155
3215
|
constructor(noUncheckedIndexedAccess) {
|
|
3156
3216
|
super();
|
|
@@ -3168,7 +3228,7 @@ var OptionalChainNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
|
3168
3228
|
return [];
|
|
3169
3229
|
}
|
|
3170
3230
|
const typeLeft = symbolLeft.tsType;
|
|
3171
|
-
if (typeLeft.flags & (
|
|
3231
|
+
if (typeLeft.flags & (ts22.TypeFlags.Any | ts22.TypeFlags.Unknown)) {
|
|
3172
3232
|
return [];
|
|
3173
3233
|
}
|
|
3174
3234
|
if (typeLeft.getNonNullableType() !== typeLeft)
|
|
@@ -3473,8 +3533,72 @@ var factory15 = {
|
|
|
3473
3533
|
create: () => new UninvokedFunctionInTextInterpolation()
|
|
3474
3534
|
};
|
|
3475
3535
|
|
|
3536
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/defer_trigger_misconfiguration/index.js
|
|
3537
|
+
import { TmplAstDeferredBlock, TmplAstHoverDeferredTrigger, TmplAstImmediateDeferredTrigger, TmplAstInteractionDeferredTrigger, TmplAstTimerDeferredTrigger, TmplAstViewportDeferredTrigger } from "@angular/compiler";
|
|
3538
|
+
var DeferTriggerMisconfiguration = class extends TemplateCheckWithVisitor {
|
|
3539
|
+
code = ErrorCode.DEFER_TRIGGER_MISCONFIGURATION;
|
|
3540
|
+
visitNode(ctx, component, node) {
|
|
3541
|
+
if (!(node instanceof TmplAstDeferredBlock))
|
|
3542
|
+
return [];
|
|
3543
|
+
const mainKeys = Object.keys(node.triggers);
|
|
3544
|
+
const prefetchKeys = Object.keys(node.prefetchTriggers);
|
|
3545
|
+
const mains = mainKeys.map((k) => node.triggers[k]).filter((t) => t !== void 0 && t !== null);
|
|
3546
|
+
const prefetches = prefetchKeys.map((k) => node.prefetchTriggers[k]).filter((t) => t !== void 0 && t !== null);
|
|
3547
|
+
const diags = [];
|
|
3548
|
+
const hasImmediateMain = mains.some((t) => t instanceof TmplAstImmediateDeferredTrigger);
|
|
3549
|
+
if (hasImmediateMain) {
|
|
3550
|
+
if (mains.length > 1) {
|
|
3551
|
+
const msg = `The 'immediate' trigger makes additional triggers redundant.`;
|
|
3552
|
+
diags.push(ctx.makeTemplateDiagnostic(node.sourceSpan, msg));
|
|
3553
|
+
}
|
|
3554
|
+
if (prefetches.length > 0) {
|
|
3555
|
+
const msg = `Prefetch triggers have no effect because 'immediate' executes earlier.`;
|
|
3556
|
+
diags.push(ctx.makeTemplateDiagnostic(node.sourceSpan, msg));
|
|
3557
|
+
}
|
|
3558
|
+
}
|
|
3559
|
+
if (mains.length === 1 && prefetches.length > 0) {
|
|
3560
|
+
const main = mains[0];
|
|
3561
|
+
for (const pre of prefetches) {
|
|
3562
|
+
const isTimerTriggger = main instanceof TmplAstTimerDeferredTrigger && pre instanceof TmplAstTimerDeferredTrigger;
|
|
3563
|
+
if (isTimerTriggger) {
|
|
3564
|
+
const mainDelay = main.delay;
|
|
3565
|
+
const preDelay = pre.delay;
|
|
3566
|
+
if (preDelay >= mainDelay) {
|
|
3567
|
+
const msg = `The Prefetch 'timer(${preDelay}ms)' is not scheduled before the main 'timer(${mainDelay}ms)', so it won\u2019t run prior to rendering. Lower the prefetch delay or remove it.`;
|
|
3568
|
+
diags.push(ctx.makeTemplateDiagnostic(pre.sourceSpan ?? node.sourceSpan, msg));
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
const isHoverTrigger = main instanceof TmplAstHoverDeferredTrigger && pre instanceof TmplAstHoverDeferredTrigger;
|
|
3572
|
+
const isInteractionTrigger = main instanceof TmplAstInteractionDeferredTrigger && pre instanceof TmplAstInteractionDeferredTrigger;
|
|
3573
|
+
const isViewportTrigger = main instanceof TmplAstViewportDeferredTrigger && pre instanceof TmplAstViewportDeferredTrigger;
|
|
3574
|
+
if (isHoverTrigger || isInteractionTrigger || isViewportTrigger) {
|
|
3575
|
+
const mainRef = main.reference;
|
|
3576
|
+
const preRef = pre.reference;
|
|
3577
|
+
if (mainRef && preRef && mainRef === preRef) {
|
|
3578
|
+
const kindName = main.constructor.name.replace("DeferredTrigger", "").toLowerCase();
|
|
3579
|
+
const msg = `Prefetch '${kindName}' matches the main trigger and provides no benefit. Remove the prefetch modifier.`;
|
|
3580
|
+
diags.push(ctx.makeTemplateDiagnostic(pre.sourceSpan ?? node.sourceSpan, msg));
|
|
3581
|
+
}
|
|
3582
|
+
continue;
|
|
3583
|
+
}
|
|
3584
|
+
if (main.constructor === pre.constructor && !(main instanceof TmplAstTimerDeferredTrigger)) {
|
|
3585
|
+
const kind = main instanceof TmplAstImmediateDeferredTrigger ? "immediate" : main.constructor.name.replace("DeferredTrigger", "").toLowerCase();
|
|
3586
|
+
const msg = `Prefetch '${kind}' matches the main trigger and provides no benefit. Remove the prefetch modifier.`;
|
|
3587
|
+
diags.push(ctx.makeTemplateDiagnostic(pre.sourceSpan ?? node.sourceSpan, msg));
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
return diags;
|
|
3592
|
+
}
|
|
3593
|
+
};
|
|
3594
|
+
var factory16 = {
|
|
3595
|
+
code: ErrorCode.DEFER_TRIGGER_MISCONFIGURATION,
|
|
3596
|
+
name: ExtendedTemplateDiagnosticName.DEFER_TRIGGER_MISCONFIGURATION,
|
|
3597
|
+
create: () => new DeferTriggerMisconfiguration()
|
|
3598
|
+
};
|
|
3599
|
+
|
|
3476
3600
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/src/extended_template_checker.js
|
|
3477
|
-
import
|
|
3601
|
+
import ts23 from "typescript";
|
|
3478
3602
|
|
|
3479
3603
|
// packages/compiler-cli/src/ngtsc/core/api/src/public_options.js
|
|
3480
3604
|
var DiagnosticCategoryLabel;
|
|
@@ -3491,12 +3615,12 @@ var ExtendedTemplateCheckerImpl = class {
|
|
|
3491
3615
|
constructor(templateTypeChecker, typeChecker, templateCheckFactories, options) {
|
|
3492
3616
|
this.partialCtx = { templateTypeChecker, typeChecker };
|
|
3493
3617
|
this.templateChecks = /* @__PURE__ */ new Map();
|
|
3494
|
-
for (const
|
|
3495
|
-
const category = diagnosticLabelToCategory(options?.extendedDiagnostics?.checks?.[
|
|
3618
|
+
for (const factory17 of templateCheckFactories) {
|
|
3619
|
+
const category = diagnosticLabelToCategory(options?.extendedDiagnostics?.checks?.[factory17.name] ?? options?.extendedDiagnostics?.defaultCategory ?? DiagnosticCategoryLabel.Warning);
|
|
3496
3620
|
if (category === null) {
|
|
3497
3621
|
continue;
|
|
3498
3622
|
}
|
|
3499
|
-
const check =
|
|
3623
|
+
const check = factory17.create(options);
|
|
3500
3624
|
if (check === null) {
|
|
3501
3625
|
continue;
|
|
3502
3626
|
}
|
|
@@ -3526,9 +3650,9 @@ var ExtendedTemplateCheckerImpl = class {
|
|
|
3526
3650
|
function diagnosticLabelToCategory(label) {
|
|
3527
3651
|
switch (label) {
|
|
3528
3652
|
case DiagnosticCategoryLabel.Warning:
|
|
3529
|
-
return
|
|
3653
|
+
return ts23.DiagnosticCategory.Warning;
|
|
3530
3654
|
case DiagnosticCategoryLabel.Error:
|
|
3531
|
-
return
|
|
3655
|
+
return ts23.DiagnosticCategory.Error;
|
|
3532
3656
|
case DiagnosticCategoryLabel.Suppress:
|
|
3533
3657
|
return null;
|
|
3534
3658
|
default:
|
|
@@ -3556,17 +3680,18 @@ var ALL_DIAGNOSTIC_FACTORIES = [
|
|
|
3556
3680
|
factory8,
|
|
3557
3681
|
factory12,
|
|
3558
3682
|
factory14,
|
|
3559
|
-
factory15
|
|
3683
|
+
factory15,
|
|
3684
|
+
factory16
|
|
3560
3685
|
];
|
|
3561
3686
|
var SUPPORTED_DIAGNOSTIC_NAMES = /* @__PURE__ */ new Set([
|
|
3562
3687
|
ExtendedTemplateDiagnosticName.CONTROL_FLOW_PREVENTING_CONTENT_PROJECTION,
|
|
3563
3688
|
ExtendedTemplateDiagnosticName.UNUSED_STANDALONE_IMPORTS,
|
|
3564
|
-
...ALL_DIAGNOSTIC_FACTORIES.map((
|
|
3689
|
+
...ALL_DIAGNOSTIC_FACTORIES.map((factory17) => factory17.name)
|
|
3565
3690
|
]);
|
|
3566
3691
|
|
|
3567
3692
|
// packages/compiler-cli/src/ngtsc/typecheck/template_semantics/src/template_semantics_checker.js
|
|
3568
3693
|
import { ASTWithSource as ASTWithSource5, ImplicitReceiver as ImplicitReceiver2, ParsedEventType as ParsedEventType2, PropertyRead as PropertyRead6, Binary as Binary3, RecursiveAstVisitor, TmplAstBoundEvent as TmplAstBoundEvent3, TmplAstLetDeclaration as TmplAstLetDeclaration2, TmplAstRecursiveVisitor, TmplAstVariable as TmplAstVariable2 } from "@angular/compiler";
|
|
3569
|
-
import
|
|
3694
|
+
import ts24 from "typescript";
|
|
3570
3695
|
var TemplateSemanticsCheckerImpl = class {
|
|
3571
3696
|
templateTypeChecker;
|
|
3572
3697
|
constructor(templateTypeChecker) {
|
|
@@ -3649,7 +3774,7 @@ var ExpressionsSemanticsVisitor = class extends RecursiveAstVisitor {
|
|
|
3649
3774
|
}
|
|
3650
3775
|
makeIllegalTemplateVarDiagnostic(target, expressionNode, errorMessage) {
|
|
3651
3776
|
const span = target instanceof TmplAstVariable2 ? target.valueSpan || target.sourceSpan : target.sourceSpan;
|
|
3652
|
-
return this.templateTypeChecker.makeTemplateDiagnostic(this.component, expressionNode.handlerSpan,
|
|
3777
|
+
return this.templateTypeChecker.makeTemplateDiagnostic(this.component, expressionNode.handlerSpan, ts24.DiagnosticCategory.Error, ngErrorCode(ErrorCode.WRITE_TO_READ_ONLY_VARIABLE), errorMessage, [
|
|
3653
3778
|
{
|
|
3654
3779
|
text: `'${target.name}' is declared here.`,
|
|
3655
3780
|
start: span.start.offset,
|
|
@@ -3664,7 +3789,7 @@ function unwrapAstWithSource(ast) {
|
|
|
3664
3789
|
}
|
|
3665
3790
|
|
|
3666
3791
|
// packages/compiler-cli/src/ngtsc/validation/src/rules/initializer_api_usage_rule.js
|
|
3667
|
-
import
|
|
3792
|
+
import ts25 from "typescript";
|
|
3668
3793
|
var APIS_TO_CHECK = [
|
|
3669
3794
|
INPUT_INITIALIZER_FN,
|
|
3670
3795
|
MODEL_INITIALIZER_FN,
|
|
@@ -3684,13 +3809,13 @@ var InitializerApiUsageRule = class {
|
|
|
3684
3809
|
});
|
|
3685
3810
|
}
|
|
3686
3811
|
checkNode(node) {
|
|
3687
|
-
if (!
|
|
3812
|
+
if (!ts25.isCallExpression(node)) {
|
|
3688
3813
|
return null;
|
|
3689
3814
|
}
|
|
3690
|
-
while (node.parent && (
|
|
3815
|
+
while (node.parent && (ts25.isParenthesizedExpression(node.parent) || ts25.isAsExpression(node.parent))) {
|
|
3691
3816
|
node = node.parent;
|
|
3692
3817
|
}
|
|
3693
|
-
if (!node.parent || !
|
|
3818
|
+
if (!node.parent || !ts25.isCallExpression(node)) {
|
|
3694
3819
|
return null;
|
|
3695
3820
|
}
|
|
3696
3821
|
const identifiedInitializer = tryParseInitializerApi(APIS_TO_CHECK, node, this.reflector, this.importedSymbolsTracker);
|
|
@@ -3698,12 +3823,12 @@ var InitializerApiUsageRule = class {
|
|
|
3698
3823
|
return null;
|
|
3699
3824
|
}
|
|
3700
3825
|
const functionName = identifiedInitializer.api.functionName + (identifiedInitializer.isRequired ? ".required" : "");
|
|
3701
|
-
if (
|
|
3826
|
+
if (ts25.isPropertyDeclaration(node.parent) && node.parent.initializer === node) {
|
|
3702
3827
|
let closestClass = node.parent;
|
|
3703
|
-
while (closestClass && !
|
|
3828
|
+
while (closestClass && !ts25.isClassDeclaration(closestClass)) {
|
|
3704
3829
|
closestClass = closestClass.parent;
|
|
3705
3830
|
}
|
|
3706
|
-
if (closestClass &&
|
|
3831
|
+
if (closestClass && ts25.isClassDeclaration(closestClass)) {
|
|
3707
3832
|
const decorators = this.reflector.getDecoratorsOfDeclaration(closestClass);
|
|
3708
3833
|
const isComponentOrDirective = decorators !== null && decorators.some((decorator) => {
|
|
3709
3834
|
return decorator.import?.from === "@angular/core" && (decorator.name === "Component" || decorator.name === "Directive");
|
|
@@ -3716,7 +3841,7 @@ var InitializerApiUsageRule = class {
|
|
|
3716
3841
|
};
|
|
3717
3842
|
|
|
3718
3843
|
// packages/compiler-cli/src/ngtsc/validation/src/rules/unused_standalone_imports_rule.js
|
|
3719
|
-
import
|
|
3844
|
+
import ts26 from "typescript";
|
|
3720
3845
|
var UnusedStandaloneImportsRule = class {
|
|
3721
3846
|
templateTypeChecker;
|
|
3722
3847
|
typeCheckingConfig;
|
|
@@ -3730,7 +3855,7 @@ var UnusedStandaloneImportsRule = class {
|
|
|
3730
3855
|
return this.typeCheckingConfig.unusedStandaloneImports !== "suppress" && (this.importedSymbolsTracker.hasNamedImport(sourceFile, "Component", "@angular/core") || this.importedSymbolsTracker.hasNamespaceImport(sourceFile, "@angular/core"));
|
|
3731
3856
|
}
|
|
3732
3857
|
checkNode(node) {
|
|
3733
|
-
if (!
|
|
3858
|
+
if (!ts26.isClassDeclaration(node)) {
|
|
3734
3859
|
return null;
|
|
3735
3860
|
}
|
|
3736
3861
|
const metadata = this.templateTypeChecker.getDirectiveMetadata(node);
|
|
@@ -3746,8 +3871,8 @@ var UnusedStandaloneImportsRule = class {
|
|
|
3746
3871
|
if (unused === null) {
|
|
3747
3872
|
return null;
|
|
3748
3873
|
}
|
|
3749
|
-
const propertyAssignment = closestNode(metadata.rawImports,
|
|
3750
|
-
const category = this.typeCheckingConfig.unusedStandaloneImports === "error" ?
|
|
3874
|
+
const propertyAssignment = closestNode(metadata.rawImports, ts26.isPropertyAssignment);
|
|
3875
|
+
const category = this.typeCheckingConfig.unusedStandaloneImports === "error" ? ts26.DiagnosticCategory.Error : ts26.DiagnosticCategory.Warning;
|
|
3751
3876
|
if (unused.length === metadata.imports.length && propertyAssignment !== null) {
|
|
3752
3877
|
return makeDiagnostic(ErrorCode.UNUSED_STANDALONE_IMPORTS, propertyAssignment.name, "All imports are unused", void 0, category);
|
|
3753
3878
|
}
|
|
@@ -3791,8 +3916,8 @@ var UnusedStandaloneImportsRule = class {
|
|
|
3791
3916
|
}
|
|
3792
3917
|
let current = reference.getIdentityIn(rawImports.getSourceFile());
|
|
3793
3918
|
while (current !== null) {
|
|
3794
|
-
if (
|
|
3795
|
-
return !!current.modifiers?.some((m) => m.kind ===
|
|
3919
|
+
if (ts26.isVariableStatement(current)) {
|
|
3920
|
+
return !!current.modifiers?.some((m) => m.kind === ts26.SyntaxKind.ExportKeyword);
|
|
3796
3921
|
}
|
|
3797
3922
|
current = current.parent ?? null;
|
|
3798
3923
|
}
|
|
@@ -3812,7 +3937,7 @@ function closestNode(start, predicate) {
|
|
|
3812
3937
|
}
|
|
3813
3938
|
|
|
3814
3939
|
// packages/compiler-cli/src/ngtsc/validation/src/rules/forbidden_required_initializer_invocation_rule.js
|
|
3815
|
-
import
|
|
3940
|
+
import ts27 from "typescript";
|
|
3816
3941
|
var APIS_TO_CHECK2 = [
|
|
3817
3942
|
INPUT_INITIALIZER_FN,
|
|
3818
3943
|
MODEL_INITIALIZER_FN,
|
|
@@ -3831,12 +3956,12 @@ var ForbiddenRequiredInitializersInvocationRule = class {
|
|
|
3831
3956
|
});
|
|
3832
3957
|
}
|
|
3833
3958
|
checkNode(node) {
|
|
3834
|
-
if (!
|
|
3959
|
+
if (!ts27.isClassDeclaration(node))
|
|
3835
3960
|
return null;
|
|
3836
|
-
const requiredInitializerDeclarations = node.members.filter((m) =>
|
|
3961
|
+
const requiredInitializerDeclarations = node.members.filter((m) => ts27.isPropertyDeclaration(m) && this.isPropDeclarationARequiredInitializer(m));
|
|
3837
3962
|
const diagnostics = [];
|
|
3838
3963
|
for (let decl of node.members) {
|
|
3839
|
-
if (!
|
|
3964
|
+
if (!ts27.isPropertyDeclaration(decl))
|
|
3840
3965
|
continue;
|
|
3841
3966
|
const initiallizerExpr = decl.initializer;
|
|
3842
3967
|
if (!initiallizerExpr)
|
|
@@ -3844,10 +3969,10 @@ var ForbiddenRequiredInitializersInvocationRule = class {
|
|
|
3844
3969
|
checkForbiddenInvocation(initiallizerExpr);
|
|
3845
3970
|
}
|
|
3846
3971
|
function checkForbiddenInvocation(node2) {
|
|
3847
|
-
if (
|
|
3972
|
+
if (ts27.isArrowFunction(node2) || ts27.isFunctionExpression(node2))
|
|
3848
3973
|
return;
|
|
3849
|
-
if (
|
|
3850
|
-
|
|
3974
|
+
if (ts27.isPropertyAccessExpression(node2) && node2.expression.kind === ts27.SyntaxKind.ThisKeyword && // With the following we make sure we only flag invoked required initializers
|
|
3975
|
+
ts27.isCallExpression(node2.parent) && node2.parent.expression === node2) {
|
|
3851
3976
|
const requiredProp = requiredInitializerDeclarations.find((prop) => prop.name.getText() === node2.name.getText());
|
|
3852
3977
|
if (requiredProp) {
|
|
3853
3978
|
const initializerFn = requiredProp.initializer.expression.expression.getText();
|
|
@@ -3872,7 +3997,7 @@ var ForbiddenRequiredInitializersInvocationRule = class {
|
|
|
3872
3997
|
}
|
|
3873
3998
|
};
|
|
3874
3999
|
function getConstructorFromClass(node) {
|
|
3875
|
-
return node.members.find((m) =>
|
|
4000
|
+
return node.members.find((m) => ts27.isConstructorDeclaration(m) && m.body !== void 0);
|
|
3876
4001
|
}
|
|
3877
4002
|
|
|
3878
4003
|
// packages/compiler-cli/src/ngtsc/validation/src/source_file_validator.js
|
|
@@ -4081,7 +4206,7 @@ var NgCompiler = class _NgCompiler {
|
|
|
4081
4206
|
this.currentProgram = inputProgram;
|
|
4082
4207
|
this.closureCompilerEnabled = !!this.options.annotateForClosureCompiler;
|
|
4083
4208
|
this.entryPoint = adapter.entryPoint !== null ? getSourceFileOrNull(inputProgram, adapter.entryPoint) : null;
|
|
4084
|
-
const moduleResolutionCache =
|
|
4209
|
+
const moduleResolutionCache = ts28.createModuleResolutionCache(
|
|
4085
4210
|
this.adapter.getCurrentDirectory(),
|
|
4086
4211
|
// doen't retain a reference to `this`, if other closures in the constructor here reference
|
|
4087
4212
|
// `this` internally then a closure created here would retain them. This can cause major
|
|
@@ -4129,7 +4254,7 @@ var NgCompiler = class _NgCompiler {
|
|
|
4129
4254
|
}
|
|
4130
4255
|
for (const clazz of classesToUpdate) {
|
|
4131
4256
|
this.compilation.traitCompiler.updateResources(clazz);
|
|
4132
|
-
if (!
|
|
4257
|
+
if (!ts28.isClassDeclaration(clazz)) {
|
|
4133
4258
|
continue;
|
|
4134
4259
|
}
|
|
4135
4260
|
this.compilation.templateTypeChecker.invalidateClass(clazz);
|
|
@@ -4339,12 +4464,12 @@ var NgCompiler = class _NgCompiler {
|
|
|
4339
4464
|
if (compilation.supportJitMode && compilation.jitDeclarationRegistry.jitDeclarations.size > 0) {
|
|
4340
4465
|
const { jitDeclarations } = compilation.jitDeclarationRegistry;
|
|
4341
4466
|
const jitDeclarationsArray = Array.from(jitDeclarations);
|
|
4342
|
-
const jitDeclarationOriginalNodes = new Set(jitDeclarationsArray.map((d) =>
|
|
4467
|
+
const jitDeclarationOriginalNodes = new Set(jitDeclarationsArray.map((d) => ts28.getOriginalNode(d)));
|
|
4343
4468
|
const sourceFilesWithJit = new Set(jitDeclarationsArray.map((d) => d.getSourceFile().fileName));
|
|
4344
4469
|
before.push((ctx) => {
|
|
4345
4470
|
const reflectionHost = new TypeScriptReflectionHost(this.inputProgram.getTypeChecker());
|
|
4346
4471
|
const jitTransform = angularJitApplicationTransform(this.inputProgram, compilation.isCore, (node) => {
|
|
4347
|
-
node =
|
|
4472
|
+
node = ts28.getOriginalNode(node, ts28.isClassDeclaration);
|
|
4348
4473
|
return reflectionHost.isClass(node) && jitDeclarationOriginalNodes.has(node);
|
|
4349
4474
|
})(ctx);
|
|
4350
4475
|
return (sourceFile) => {
|
|
@@ -4423,16 +4548,16 @@ var NgCompiler = class _NgCompiler {
|
|
|
4423
4548
|
return null;
|
|
4424
4549
|
}
|
|
4425
4550
|
const sourceFile = node.getSourceFile();
|
|
4426
|
-
const printer =
|
|
4427
|
-
const nodeText = printer.printNode(
|
|
4428
|
-
return
|
|
4551
|
+
const printer = ts28.createPrinter();
|
|
4552
|
+
const nodeText = printer.printNode(ts28.EmitHint.Unspecified, callback, sourceFile);
|
|
4553
|
+
return ts28.transpileModule(nodeText, {
|
|
4429
4554
|
compilerOptions: {
|
|
4430
4555
|
...this.options,
|
|
4431
4556
|
// Some module types can produce additional code (see #60795) whereas we need the
|
|
4432
4557
|
// HMR update module to use a native `export`. Override the `target` and `module`
|
|
4433
4558
|
// to ensure that it looks as expected.
|
|
4434
|
-
module:
|
|
4435
|
-
target:
|
|
4559
|
+
module: ts28.ModuleKind.ES2022,
|
|
4560
|
+
target: ts28.ScriptTarget.ES2022
|
|
4436
4561
|
},
|
|
4437
4562
|
fileName: sourceFile.fileName,
|
|
4438
4563
|
reportDiagnostics: false
|
|
@@ -4808,18 +4933,18 @@ function isAngularCorePackage(program) {
|
|
|
4808
4933
|
return false;
|
|
4809
4934
|
}
|
|
4810
4935
|
return r3Symbols.statements.some((stmt) => {
|
|
4811
|
-
if (!
|
|
4936
|
+
if (!ts28.isVariableStatement(stmt)) {
|
|
4812
4937
|
return false;
|
|
4813
4938
|
}
|
|
4814
|
-
const modifiers =
|
|
4815
|
-
if (modifiers === void 0 || !modifiers.some((mod) => mod.kind ===
|
|
4939
|
+
const modifiers = ts28.getModifiers(stmt);
|
|
4940
|
+
if (modifiers === void 0 || !modifiers.some((mod) => mod.kind === ts28.SyntaxKind.ExportKeyword)) {
|
|
4816
4941
|
return false;
|
|
4817
4942
|
}
|
|
4818
4943
|
return stmt.declarationList.declarations.some((decl) => {
|
|
4819
|
-
if (!
|
|
4944
|
+
if (!ts28.isIdentifier(decl.name) || decl.name.text !== "ITS_JUST_ANGULAR") {
|
|
4820
4945
|
return false;
|
|
4821
4946
|
}
|
|
4822
|
-
if (decl.initializer === void 0 || decl.initializer.kind !==
|
|
4947
|
+
if (decl.initializer === void 0 || decl.initializer.kind !== ts28.SyntaxKind.TrueKeyword) {
|
|
4823
4948
|
return false;
|
|
4824
4949
|
}
|
|
4825
4950
|
return true;
|
|
@@ -4832,7 +4957,7 @@ function getR3SymbolsFile(program) {
|
|
|
4832
4957
|
function* verifyCompatibleTypeCheckOptions(options) {
|
|
4833
4958
|
if (options.fullTemplateTypeCheck === false && options.strictTemplates === true) {
|
|
4834
4959
|
yield makeConfigDiagnostic({
|
|
4835
|
-
category:
|
|
4960
|
+
category: ts28.DiagnosticCategory.Error,
|
|
4836
4961
|
code: ErrorCode.CONFIG_STRICT_TEMPLATES_IMPLIES_FULL_TEMPLATE_TYPECHECK,
|
|
4837
4962
|
messageText: `
|
|
4838
4963
|
Angular compiler option "strictTemplates" is enabled, however "fullTemplateTypeCheck" is disabled.
|
|
@@ -4851,7 +4976,7 @@ https://angular.dev/tools/cli/template-typecheck
|
|
|
4851
4976
|
}
|
|
4852
4977
|
if (options.extendedDiagnostics && options.strictTemplates === false) {
|
|
4853
4978
|
yield makeConfigDiagnostic({
|
|
4854
|
-
category:
|
|
4979
|
+
category: ts28.DiagnosticCategory.Error,
|
|
4855
4980
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_IMPLIES_STRICT_TEMPLATES,
|
|
4856
4981
|
messageText: `
|
|
4857
4982
|
Angular compiler option "extendedDiagnostics" is configured, however "strictTemplates" is disabled.
|
|
@@ -4868,7 +4993,7 @@ One of the following actions is required:
|
|
|
4868
4993
|
const defaultCategory = options.extendedDiagnostics?.defaultCategory;
|
|
4869
4994
|
if (defaultCategory && !allowedCategoryLabels.includes(defaultCategory)) {
|
|
4870
4995
|
yield makeConfigDiagnostic({
|
|
4871
|
-
category:
|
|
4996
|
+
category: ts28.DiagnosticCategory.Error,
|
|
4872
4997
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL,
|
|
4873
4998
|
messageText: `
|
|
4874
4999
|
Angular compiler option "extendedDiagnostics.defaultCategory" has an unknown diagnostic category: "${defaultCategory}".
|
|
@@ -4881,7 +5006,7 @@ ${allowedCategoryLabels.join("\n")}
|
|
|
4881
5006
|
for (const [checkName, category] of Object.entries(options.extendedDiagnostics?.checks ?? {})) {
|
|
4882
5007
|
if (!SUPPORTED_DIAGNOSTIC_NAMES.has(checkName)) {
|
|
4883
5008
|
yield makeConfigDiagnostic({
|
|
4884
|
-
category:
|
|
5009
|
+
category: ts28.DiagnosticCategory.Error,
|
|
4885
5010
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CHECK,
|
|
4886
5011
|
messageText: `
|
|
4887
5012
|
Angular compiler option "extendedDiagnostics.checks" has an unknown check: "${checkName}".
|
|
@@ -4893,7 +5018,7 @@ ${Array.from(SUPPORTED_DIAGNOSTIC_NAMES).join("\n")}
|
|
|
4893
5018
|
}
|
|
4894
5019
|
if (!allowedCategoryLabels.includes(category)) {
|
|
4895
5020
|
yield makeConfigDiagnostic({
|
|
4896
|
-
category:
|
|
5021
|
+
category: ts28.DiagnosticCategory.Error,
|
|
4897
5022
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL,
|
|
4898
5023
|
messageText: `
|
|
4899
5024
|
Angular compiler option "extendedDiagnostics.checks['${checkName}']" has an unknown diagnostic category: "${category}".
|
|
@@ -4911,7 +5036,7 @@ function verifyEmitDeclarationOnly(options) {
|
|
|
4911
5036
|
}
|
|
4912
5037
|
return [
|
|
4913
5038
|
makeConfigDiagnostic({
|
|
4914
|
-
category:
|
|
5039
|
+
category: ts28.DiagnosticCategory.Error,
|
|
4915
5040
|
code: ErrorCode.CONFIG_EMIT_DECLARATION_ONLY_UNSUPPORTED,
|
|
4916
5041
|
messageText: 'TS compiler option "emitDeclarationOnly" is not supported.'
|
|
4917
5042
|
})
|
|
@@ -4936,7 +5061,7 @@ var ReferenceGraphAdapter = class {
|
|
|
4936
5061
|
for (const { node } of references) {
|
|
4937
5062
|
let sourceFile = node.getSourceFile();
|
|
4938
5063
|
if (sourceFile === void 0) {
|
|
4939
|
-
sourceFile =
|
|
5064
|
+
sourceFile = ts28.getOriginalNode(node).getSourceFile();
|
|
4940
5065
|
}
|
|
4941
5066
|
if (sourceFile === void 0 || !isDtsPath(sourceFile.fileName)) {
|
|
4942
5067
|
this.graph.add(source, node);
|
|
@@ -4977,7 +5102,7 @@ function versionMapFromProgram(program, driver) {
|
|
|
4977
5102
|
}
|
|
4978
5103
|
|
|
4979
5104
|
// packages/compiler-cli/src/ngtsc/core/src/host.js
|
|
4980
|
-
import
|
|
5105
|
+
import ts29 from "typescript";
|
|
4981
5106
|
var DelegatingCompilerHost = class {
|
|
4982
5107
|
delegate;
|
|
4983
5108
|
createHash;
|
|
@@ -5116,7 +5241,7 @@ var NgCompilerHost = class _NgCompilerHost extends DelegatingCompilerHost {
|
|
|
5116
5241
|
entryPoint = findFlatIndexEntryPoint(normalizedTsInputFiles);
|
|
5117
5242
|
if (entryPoint === null) {
|
|
5118
5243
|
diagnostics.push({
|
|
5119
|
-
category:
|
|
5244
|
+
category: ts29.DiagnosticCategory.Error,
|
|
5120
5245
|
code: ngErrorCode(ErrorCode.CONFIG_FLAT_MODULE_NO_INDEX),
|
|
5121
5246
|
file: void 0,
|
|
5122
5247
|
start: void 0,
|
|
@@ -5170,10 +5295,10 @@ var NgCompilerHost = class _NgCompilerHost extends DelegatingCompilerHost {
|
|
|
5170
5295
|
return this.fileNameToModuleName !== void 0 ? this : null;
|
|
5171
5296
|
}
|
|
5172
5297
|
createCachedResolveModuleNamesFunction() {
|
|
5173
|
-
const moduleResolutionCache =
|
|
5298
|
+
const moduleResolutionCache = ts29.createModuleResolutionCache(this.getCurrentDirectory(), this.getCanonicalFileName.bind(this));
|
|
5174
5299
|
return (moduleNames, containingFile, reusedNames, redirectedReference, options) => {
|
|
5175
5300
|
return moduleNames.map((moduleName) => {
|
|
5176
|
-
const module =
|
|
5301
|
+
const module = ts29.resolveModuleName(moduleName, containingFile, options, this, moduleResolutionCache, redirectedReference);
|
|
5177
5302
|
return module.resolvedModule;
|
|
5178
5303
|
});
|
|
5179
5304
|
};
|
|
@@ -5205,7 +5330,7 @@ var NgtscProgram = class {
|
|
|
5205
5330
|
if (reuseProgram !== void 0) {
|
|
5206
5331
|
retagAllTsFiles(reuseProgram);
|
|
5207
5332
|
}
|
|
5208
|
-
this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () =>
|
|
5333
|
+
this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () => ts30.createProgram(this.host.inputFiles, options, this.host, reuseProgram));
|
|
5209
5334
|
perfRecorder.phase(PerfPhase.Unaccounted);
|
|
5210
5335
|
perfRecorder.memory(PerfCheckpoint.TypeScriptProgramCreate);
|
|
5211
5336
|
this.host.postProgramCreationCleanup();
|
|
@@ -5434,16 +5559,16 @@ function createProgram({ rootNames, options, host, oldProgram }) {
|
|
|
5434
5559
|
}
|
|
5435
5560
|
|
|
5436
5561
|
// packages/compiler-cli/src/perform_compile.js
|
|
5437
|
-
import
|
|
5562
|
+
import ts32 from "typescript";
|
|
5438
5563
|
|
|
5439
5564
|
// packages/compiler-cli/src/transformers/util.js
|
|
5440
|
-
import
|
|
5565
|
+
import ts31 from "typescript";
|
|
5441
5566
|
function createMessageDiagnostic(messageText) {
|
|
5442
5567
|
return {
|
|
5443
5568
|
file: void 0,
|
|
5444
5569
|
start: void 0,
|
|
5445
5570
|
length: void 0,
|
|
5446
|
-
category:
|
|
5571
|
+
category: ts31.DiagnosticCategory.Message,
|
|
5447
5572
|
messageText,
|
|
5448
5573
|
code: DEFAULT_ERROR_CODE,
|
|
5449
5574
|
source: SOURCE
|
|
@@ -5452,13 +5577,13 @@ function createMessageDiagnostic(messageText) {
|
|
|
5452
5577
|
|
|
5453
5578
|
// packages/compiler-cli/src/perform_compile.js
|
|
5454
5579
|
var defaultFormatHost = {
|
|
5455
|
-
getCurrentDirectory: () =>
|
|
5580
|
+
getCurrentDirectory: () => ts32.sys.getCurrentDirectory(),
|
|
5456
5581
|
getCanonicalFileName: (fileName) => fileName,
|
|
5457
|
-
getNewLine: () =>
|
|
5582
|
+
getNewLine: () => ts32.sys.newLine
|
|
5458
5583
|
};
|
|
5459
5584
|
function formatDiagnostics(diags, host = defaultFormatHost) {
|
|
5460
5585
|
if (diags && diags.length) {
|
|
5461
|
-
return diags.map((diagnostic) => replaceTsWithNgInErrors(
|
|
5586
|
+
return diags.map((diagnostic) => replaceTsWithNgInErrors(ts32.formatDiagnosticsWithColorAndContext([diagnostic], host))).join("");
|
|
5462
5587
|
} else {
|
|
5463
5588
|
return "";
|
|
5464
5589
|
}
|
|
@@ -5474,7 +5599,7 @@ function calcProjectFileAndBasePath(project, host = getFileSystem()) {
|
|
|
5474
5599
|
function readConfiguration(project, existingOptions, host = getFileSystem()) {
|
|
5475
5600
|
try {
|
|
5476
5601
|
const fs = getFileSystem();
|
|
5477
|
-
const readConfigFile = (configFile) =>
|
|
5602
|
+
const readConfigFile = (configFile) => ts32.readConfigFile(configFile, (file) => host.readFile(host.resolve(file)));
|
|
5478
5603
|
const readAngularCompilerOptions = (configFile, parentOptions = {}) => {
|
|
5479
5604
|
const { config: config2, error: error2 } = readConfigFile(configFile);
|
|
5480
5605
|
if (error2) {
|
|
@@ -5510,7 +5635,7 @@ function readConfiguration(project, existingOptions, host = getFileSystem()) {
|
|
|
5510
5635
|
...existingOptions
|
|
5511
5636
|
};
|
|
5512
5637
|
const parseConfigHost = createParseConfigHost(host, fs);
|
|
5513
|
-
const { options, errors, fileNames: rootNames, projectReferences } =
|
|
5638
|
+
const { options, errors, fileNames: rootNames, projectReferences } = ts32.parseJsonConfigFileContent(config, parseConfigHost, basePath, existingCompilerOptions, configFileName);
|
|
5514
5639
|
let emitFlags = EmitFlags.Default;
|
|
5515
5640
|
if (!(options["skipMetadataEmit"] || options["flatModuleOutFile"])) {
|
|
5516
5641
|
emitFlags |= EmitFlags.Metadata;
|
|
@@ -5522,7 +5647,7 @@ function readConfiguration(project, existingOptions, host = getFileSystem()) {
|
|
|
5522
5647
|
} catch (e) {
|
|
5523
5648
|
const errors = [
|
|
5524
5649
|
{
|
|
5525
|
-
category:
|
|
5650
|
+
category: ts32.DiagnosticCategory.Error,
|
|
5526
5651
|
messageText: e.stack ?? e.message,
|
|
5527
5652
|
file: void 0,
|
|
5528
5653
|
start: void 0,
|
|
@@ -5557,7 +5682,7 @@ function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
|
|
|
5557
5682
|
}
|
|
5558
5683
|
} else {
|
|
5559
5684
|
const parseConfigHost = createParseConfigHost(host, fs);
|
|
5560
|
-
const { resolvedModule } =
|
|
5685
|
+
const { resolvedModule } = ts32.nodeModuleNameResolver(extendsValue, configFile, { moduleResolution: ts32.ModuleResolutionKind.Node10, resolveJsonModule: true }, parseConfigHost);
|
|
5561
5686
|
if (resolvedModule) {
|
|
5562
5687
|
return absoluteFrom(resolvedModule.resolvedFileName);
|
|
5563
5688
|
}
|
|
@@ -5567,7 +5692,7 @@ function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
|
|
|
5567
5692
|
function exitCodeFromResult(diags) {
|
|
5568
5693
|
if (!diags)
|
|
5569
5694
|
return 0;
|
|
5570
|
-
if (diags.every((diag) => diag.category !==
|
|
5695
|
+
if (diags.every((diag) => diag.category !== ts32.DiagnosticCategory.Error)) {
|
|
5571
5696
|
return 0;
|
|
5572
5697
|
}
|
|
5573
5698
|
return diags.some((d) => d.source === "angular" && d.code === UNKNOWN_ERROR_CODE) ? 2 : 1;
|
|
@@ -5605,7 +5730,7 @@ function performCompilation({ rootNames, options, host, oldProgram, emitCallback
|
|
|
5605
5730
|
} catch (e) {
|
|
5606
5731
|
program = void 0;
|
|
5607
5732
|
allDiagnostics.push({
|
|
5608
|
-
category:
|
|
5733
|
+
category: ts32.DiagnosticCategory.Error,
|
|
5609
5734
|
messageText: e.stack ?? e.message,
|
|
5610
5735
|
code: UNKNOWN_ERROR_CODE,
|
|
5611
5736
|
file: void 0,
|
|
@@ -5635,7 +5760,7 @@ function defaultGatherDiagnostics(program) {
|
|
|
5635
5760
|
return allDiagnostics;
|
|
5636
5761
|
}
|
|
5637
5762
|
function hasErrors(diags) {
|
|
5638
|
-
return diags.some((d) => d.category ===
|
|
5763
|
+
return diags.some((d) => d.category === ts32.DiagnosticCategory.Error);
|
|
5639
5764
|
}
|
|
5640
5765
|
|
|
5641
5766
|
export {
|