@angular/compiler-cli 20.3.0 → 20.3.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.
@@ -118,6 +118,7 @@ var ErrorCode;
118
118
  ErrorCode2[ErrorCode2["UNINVOKED_TRACK_FUNCTION"] = 8115] = "UNINVOKED_TRACK_FUNCTION";
119
119
  ErrorCode2[ErrorCode2["MISSING_STRUCTURAL_DIRECTIVE"] = 8116] = "MISSING_STRUCTURAL_DIRECTIVE";
120
120
  ErrorCode2[ErrorCode2["UNINVOKED_FUNCTION_IN_TEXT_INTERPOLATION"] = 8117] = "UNINVOKED_FUNCTION_IN_TEXT_INTERPOLATION";
121
+ ErrorCode2[ErrorCode2["FORBIDDEN_REQUIRED_INITIALIZER_INVOCATION"] = 8118] = "FORBIDDEN_REQUIRED_INITIALIZER_INVOCATION";
121
122
  ErrorCode2[ErrorCode2["INLINE_TCB_REQUIRED"] = 8900] = "INLINE_TCB_REQUIRED";
122
123
  ErrorCode2[ErrorCode2["INLINE_TYPE_CTOR_REQUIRED"] = 8901] = "INLINE_TYPE_CTOR_REQUIRED";
123
124
  ErrorCode2[ErrorCode2["INJECTABLE_DUPLICATE_PROV"] = 9001] = "INJECTABLE_DUPLICATE_PROV";
@@ -221,7 +222,11 @@ var COMPILER_ERRORS_WITH_GUIDES = /* @__PURE__ */ new Set([
221
222
  ]);
222
223
 
223
224
  // packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.js
224
- var ERROR_DETAILS_PAGE_BASE_URL = "https://angular.dev/errors";
225
+ import { VERSION } from "@angular/compiler";
226
+ var ERROR_DETAILS_PAGE_BASE_URL = (() => {
227
+ const versionSubDomain = VERSION.major !== "0" ? `v${VERSION.major}.` : "";
228
+ return `https://${versionSubDomain}angular.dev/errors`;
229
+ })();
225
230
 
226
231
  // packages/compiler-cli/src/ngtsc/diagnostics/src/extended_template_diagnostic_name.js
227
232
  var ExtendedTemplateDiagnosticName;
@@ -10978,7 +10983,7 @@ var CompletionEngine = class {
10978
10983
  // packages/compiler-cli/src/ngtsc/typecheck/src/context.js
10979
10984
  import { ParseSourceFile as ParseSourceFile2 } from "@angular/compiler";
10980
10985
 
10981
- // node_modules/.aspect_rules_js/magic-string@0.30.18/node_modules/magic-string/dist/magic-string.es.mjs
10986
+ // node_modules/.aspect_rules_js/magic-string@0.30.19/node_modules/magic-string/dist/magic-string.es.mjs
10982
10987
  import { encode } from "@jridgewell/sourcemap-codec";
10983
10988
  var BitSet = class _BitSet {
10984
10989
  constructor(arg) {
@@ -11428,6 +11433,9 @@ var MagicString = class _MagicString {
11428
11433
  if (chunk.outro.length)
11429
11434
  mappings.advance(chunk.outro);
11430
11435
  });
11436
+ if (this.outro) {
11437
+ mappings.advance(this.outro);
11438
+ }
11431
11439
  return {
11432
11440
  file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
11433
11441
  sources: [
@@ -11990,7 +11998,12 @@ var MagicString = class _MagicString {
11990
11998
  const { original } = this;
11991
11999
  const index = original.indexOf(string);
11992
12000
  if (index !== -1) {
11993
- this.overwrite(index, index + string.length, replacement);
12001
+ if (typeof replacement === "function") {
12002
+ replacement = replacement(string, index, original);
12003
+ }
12004
+ if (string !== replacement) {
12005
+ this.overwrite(index, index + string.length, replacement);
12006
+ }
11994
12007
  }
11995
12008
  return this;
11996
12009
  }
@@ -12005,8 +12018,12 @@ var MagicString = class _MagicString {
12005
12018
  const stringLength = string.length;
12006
12019
  for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
12007
12020
  const previous = original.slice(index, index + stringLength);
12008
- if (previous !== replacement)
12009
- this.overwrite(index, index + stringLength, replacement);
12021
+ let _replacement = replacement;
12022
+ if (typeof replacement === "function") {
12023
+ _replacement = replacement(previous, index, original);
12024
+ }
12025
+ if (previous !== _replacement)
12026
+ this.overwrite(index, index + stringLength, _replacement);
12010
12027
  }
12011
12028
  return this;
12012
12029
  }
@@ -15571,10 +15588,15 @@ function getBoundAttributes(directive, node) {
15571
15588
  });
15572
15589
  }
15573
15590
  };
15574
- node.inputs.forEach(processAttribute);
15575
- node.attributes.forEach(processAttribute);
15576
15591
  if (node instanceof TmplAstTemplate) {
15592
+ if (node.tagName === "ng-template") {
15593
+ node.inputs.forEach(processAttribute);
15594
+ node.attributes.forEach(processAttribute);
15595
+ }
15577
15596
  node.templateAttrs.forEach(processAttribute);
15597
+ } else {
15598
+ node.inputs.forEach(processAttribute);
15599
+ node.attributes.forEach(processAttribute);
15578
15600
  }
15579
15601
  return boundInputs;
15580
15602
  }
@@ -21061,11 +21083,12 @@ var ComponentDecoratorHandler = class {
21061
21083
  for (const [_, deps] of resolution.deferPerBlockDependencies) {
21062
21084
  for (const deferBlockDep of deps) {
21063
21085
  const node = deferBlockDep.declaration.node;
21064
- const importDecl = resolution.deferrableDeclToImportDecl.get(node) ?? null;
21065
- if (importDecl !== null && this.deferredSymbolTracker.canDefer(importDecl)) {
21086
+ const importInfo = resolution.deferrableDeclToImportDecl.get(node) ?? null;
21087
+ if (importInfo !== null && this.deferredSymbolTracker.canDefer(importInfo.node)) {
21066
21088
  deferBlockDep.isDeferrable = true;
21067
- deferBlockDep.importPath = importDecl.moduleSpecifier.text;
21068
- deferBlockDep.isDefaultImport = isDefaultImport(importDecl);
21089
+ deferBlockDep.symbolName = importInfo.name;
21090
+ deferBlockDep.importPath = importInfo.from;
21091
+ deferBlockDep.isDefaultImport = isDefaultImport(importInfo.node);
21069
21092
  if (!seenDeps.has(node)) {
21070
21093
  seenDeps.add(node);
21071
21094
  deferrableTypes.push(deferBlockDep);
@@ -21208,7 +21231,7 @@ var ComponentDecoratorHandler = class {
21208
21231
  if (dirMeta === null && pipeMeta === null) {
21209
21232
  return;
21210
21233
  }
21211
- resolutionData.deferrableDeclToImportDecl.set(decl.node, imp.node);
21234
+ resolutionData.deferrableDeclToImportDecl.set(decl.node, imp);
21212
21235
  this.deferredSymbolTracker.markAsDeferrableCandidate(node, imp.node, componentClassDecl, isDeferredImport);
21213
21236
  }
21214
21237
  compileDeferBlocks(resolution) {
@@ -16,7 +16,7 @@ import {
16
16
  tryParseSignalInputMapping,
17
17
  tryParseSignalModelMapping,
18
18
  tryParseSignalQueryFromInitializer
19
- } from "./chunk-PVSLT73R.js";
19
+ } from "./chunk-2JGGVEXA.js";
20
20
 
21
21
  // packages/compiler-cli/src/ngtsc/transform/jit/src/downlevel_decorators_transform.js
22
22
  import ts from "typescript";
@@ -4,7 +4,7 @@
4
4
 
5
5
  import {
6
6
  angularJitApplicationTransform
7
- } from "./chunk-6DF2AWLX.js";
7
+ } from "./chunk-5YTDMIWM.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-PVSLT73R.js";
95
+ } from "./chunk-2JGGVEXA.js";
96
96
  import {
97
97
  LogicalFileSystem,
98
98
  absoluteFrom,
@@ -1205,7 +1205,7 @@ function getRelativeFilePath(sourceFile, rootDir) {
1205
1205
 
1206
1206
  // packages/compiler-cli/src/ngtsc/program.js
1207
1207
  import { HtmlParser, MessageBundle } from "@angular/compiler";
1208
- import ts27 from "typescript";
1208
+ import ts28 from "typescript";
1209
1209
 
1210
1210
  // packages/compiler-cli/src/transformers/i18n.js
1211
1211
  import { Xliff, Xliff2, Xmb } from "@angular/compiler";
@@ -1310,7 +1310,7 @@ function verifySupportedTypeScriptVersion() {
1310
1310
  }
1311
1311
 
1312
1312
  // packages/compiler-cli/src/ngtsc/core/src/compiler.js
1313
- import ts25 from "typescript";
1313
+ import ts26 from "typescript";
1314
1314
 
1315
1315
  // packages/compiler-cli/src/ngtsc/cycles/src/analyzer.js
1316
1316
  var CycleAnalyzer = class {
@@ -2896,8 +2896,8 @@ var InterpolatedSignalCheck = class extends TemplateCheckWithVisitor {
2896
2896
  if (node instanceof Interpolation) {
2897
2897
  return node.expressions.map((item) => item instanceof PrefixNot ? item.expression : item).filter((item) => item instanceof PropertyRead2).flatMap((item) => buildDiagnosticForSignal(ctx, item, component));
2898
2898
  } else if (node instanceof TmplAstBoundAttribute) {
2899
- const usedDirectives = ctx.templateTypeChecker.getUsedDirectives(component);
2900
- if (usedDirectives !== null && usedDirectives.some((dir) => dir.inputs.getByBindingPropertyName(node.name) !== null)) {
2899
+ const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
2900
+ if (symbol?.kind === SymbolKind.Input && symbol.bindings.length > 0 && symbol.bindings.some((binding) => binding.target.kind === SymbolKind.Directive)) {
2901
2901
  return [];
2902
2902
  }
2903
2903
  const nodeAst = isPropertyReadNodeAst(node);
@@ -3146,14 +3146,23 @@ var factory6 = {
3146
3146
  };
3147
3147
 
3148
3148
  // packages/compiler-cli/src/ngtsc/typecheck/extended/checks/optional_chain_not_nullable/index.js
3149
- import { SafeCall, SafeKeyedRead, SafePropertyRead } from "@angular/compiler";
3149
+ import { KeyedRead, SafeCall, SafeKeyedRead, SafePropertyRead } from "@angular/compiler";
3150
3150
  import ts20 from "typescript";
3151
3151
  var OptionalChainNotNullableCheck = class extends TemplateCheckWithVisitor {
3152
+ noUncheckedIndexedAccess;
3152
3153
  canVisitStructuralAttributes = false;
3153
3154
  code = ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE;
3155
+ constructor(noUncheckedIndexedAccess) {
3156
+ super();
3157
+ this.noUncheckedIndexedAccess = noUncheckedIndexedAccess;
3158
+ }
3154
3159
  visitNode(ctx, component, node) {
3155
- if (!(node instanceof SafeCall) && !(node instanceof SafePropertyRead) && !(node instanceof SafeKeyedRead))
3160
+ if (!(node instanceof SafeCall) && !(node instanceof SafePropertyRead) && !(node instanceof SafeKeyedRead)) {
3156
3161
  return [];
3162
+ }
3163
+ if (node.receiver instanceof KeyedRead && !this.noUncheckedIndexedAccess) {
3164
+ return [];
3165
+ }
3157
3166
  const symbolLeft = ctx.templateTypeChecker.getSymbolOfNode(node.receiver, component);
3158
3167
  if (symbolLeft === null || symbolLeft.kind !== SymbolKind.Expression) {
3159
3168
  return [];
@@ -3185,7 +3194,8 @@ var factory7 = {
3185
3194
  if (!strictNullChecks) {
3186
3195
  return null;
3187
3196
  }
3188
- return new OptionalChainNotNullableCheck();
3197
+ const noUncheckedIndexedAccess = !!options.noUncheckedIndexedAccess;
3198
+ return new OptionalChainNotNullableCheck(noUncheckedIndexedAccess);
3189
3199
  }
3190
3200
  };
3191
3201
 
@@ -3801,12 +3811,77 @@ function closestNode(start, predicate) {
3801
3811
  return null;
3802
3812
  }
3803
3813
 
3814
+ // packages/compiler-cli/src/ngtsc/validation/src/rules/forbidden_required_initializer_invocation_rule.js
3815
+ import ts25 from "typescript";
3816
+ var APIS_TO_CHECK2 = [
3817
+ INPUT_INITIALIZER_FN,
3818
+ MODEL_INITIALIZER_FN,
3819
+ ...QUERY_INITIALIZER_FNS
3820
+ ];
3821
+ var ForbiddenRequiredInitializersInvocationRule = class {
3822
+ reflector;
3823
+ importedSymbolsTracker;
3824
+ constructor(reflector, importedSymbolsTracker) {
3825
+ this.reflector = reflector;
3826
+ this.importedSymbolsTracker = importedSymbolsTracker;
3827
+ }
3828
+ shouldCheck(sourceFile) {
3829
+ return APIS_TO_CHECK2.some(({ functionName, owningModule }) => {
3830
+ return this.importedSymbolsTracker.hasNamedImport(sourceFile, functionName, owningModule) || this.importedSymbolsTracker.hasNamespaceImport(sourceFile, owningModule);
3831
+ });
3832
+ }
3833
+ checkNode(node) {
3834
+ if (!ts25.isClassDeclaration(node))
3835
+ return null;
3836
+ const requiredInitializerDeclarations = node.members.filter((m) => ts25.isPropertyDeclaration(m) && this.isPropDeclarationARequiredInitializer(m));
3837
+ const diagnostics = [];
3838
+ for (let decl of node.members) {
3839
+ if (!ts25.isPropertyDeclaration(decl))
3840
+ continue;
3841
+ const initiallizerExpr = decl.initializer;
3842
+ if (!initiallizerExpr)
3843
+ continue;
3844
+ checkForbiddenInvocation(initiallizerExpr);
3845
+ }
3846
+ function checkForbiddenInvocation(node2) {
3847
+ if (ts25.isArrowFunction(node2) || ts25.isFunctionExpression(node2))
3848
+ return;
3849
+ if (ts25.isPropertyAccessExpression(node2) && node2.expression.kind === ts25.SyntaxKind.ThisKeyword && // With the following we make sure we only flag invoked required initializers
3850
+ ts25.isCallExpression(node2.parent) && node2.parent.expression === node2) {
3851
+ const requiredProp = requiredInitializerDeclarations.find((prop) => prop.name.getText() === node2.name.getText());
3852
+ if (requiredProp) {
3853
+ const initializerFn = requiredProp.initializer.expression.expression.getText();
3854
+ diagnostics.push(makeDiagnostic(ErrorCode.FORBIDDEN_REQUIRED_INITIALIZER_INVOCATION, node2, `\`${node2.name.getText()}\` is a required \`${initializerFn}\` and does not have a value in this context.`));
3855
+ }
3856
+ }
3857
+ return node2.forEachChild(checkForbiddenInvocation);
3858
+ }
3859
+ const ctor = getConstructorFromClass(node);
3860
+ if (ctor) {
3861
+ checkForbiddenInvocation(ctor);
3862
+ }
3863
+ return diagnostics;
3864
+ }
3865
+ isPropDeclarationARequiredInitializer(node) {
3866
+ if (!node.initializer)
3867
+ return false;
3868
+ const identifiedInitializer = tryParseInitializerApi(APIS_TO_CHECK2, node.initializer, this.reflector, this.importedSymbolsTracker);
3869
+ if (identifiedInitializer === null || !identifiedInitializer.isRequired)
3870
+ return false;
3871
+ return true;
3872
+ }
3873
+ };
3874
+ function getConstructorFromClass(node) {
3875
+ return node.members.find((m) => ts25.isConstructorDeclaration(m) && m.body !== void 0);
3876
+ }
3877
+
3804
3878
  // packages/compiler-cli/src/ngtsc/validation/src/source_file_validator.js
3805
3879
  var SourceFileValidator = class {
3806
3880
  rules;
3807
3881
  constructor(reflector, importedSymbolsTracker, templateTypeChecker, typeCheckingConfig) {
3808
3882
  this.rules = [new InitializerApiUsageRule(reflector, importedSymbolsTracker)];
3809
3883
  this.rules.push(new UnusedStandaloneImportsRule(templateTypeChecker, typeCheckingConfig, importedSymbolsTracker));
3884
+ this.rules.push(new ForbiddenRequiredInitializersInvocationRule(reflector, importedSymbolsTracker));
3810
3885
  }
3811
3886
  /**
3812
3887
  * Gets the diagnostics for a specific file, or null if the file is valid.
@@ -4006,7 +4081,7 @@ var NgCompiler = class _NgCompiler {
4006
4081
  this.currentProgram = inputProgram;
4007
4082
  this.closureCompilerEnabled = !!this.options.annotateForClosureCompiler;
4008
4083
  this.entryPoint = adapter.entryPoint !== null ? getSourceFileOrNull(inputProgram, adapter.entryPoint) : null;
4009
- const moduleResolutionCache = ts25.createModuleResolutionCache(
4084
+ const moduleResolutionCache = ts26.createModuleResolutionCache(
4010
4085
  this.adapter.getCurrentDirectory(),
4011
4086
  // doen't retain a reference to `this`, if other closures in the constructor here reference
4012
4087
  // `this` internally then a closure created here would retain them. This can cause major
@@ -4054,7 +4129,7 @@ var NgCompiler = class _NgCompiler {
4054
4129
  }
4055
4130
  for (const clazz of classesToUpdate) {
4056
4131
  this.compilation.traitCompiler.updateResources(clazz);
4057
- if (!ts25.isClassDeclaration(clazz)) {
4132
+ if (!ts26.isClassDeclaration(clazz)) {
4058
4133
  continue;
4059
4134
  }
4060
4135
  this.compilation.templateTypeChecker.invalidateClass(clazz);
@@ -4264,12 +4339,12 @@ var NgCompiler = class _NgCompiler {
4264
4339
  if (compilation.supportJitMode && compilation.jitDeclarationRegistry.jitDeclarations.size > 0) {
4265
4340
  const { jitDeclarations } = compilation.jitDeclarationRegistry;
4266
4341
  const jitDeclarationsArray = Array.from(jitDeclarations);
4267
- const jitDeclarationOriginalNodes = new Set(jitDeclarationsArray.map((d) => ts25.getOriginalNode(d)));
4342
+ const jitDeclarationOriginalNodes = new Set(jitDeclarationsArray.map((d) => ts26.getOriginalNode(d)));
4268
4343
  const sourceFilesWithJit = new Set(jitDeclarationsArray.map((d) => d.getSourceFile().fileName));
4269
4344
  before.push((ctx) => {
4270
4345
  const reflectionHost = new TypeScriptReflectionHost(this.inputProgram.getTypeChecker());
4271
4346
  const jitTransform = angularJitApplicationTransform(this.inputProgram, compilation.isCore, (node) => {
4272
- node = ts25.getOriginalNode(node, ts25.isClassDeclaration);
4347
+ node = ts26.getOriginalNode(node, ts26.isClassDeclaration);
4273
4348
  return reflectionHost.isClass(node) && jitDeclarationOriginalNodes.has(node);
4274
4349
  })(ctx);
4275
4350
  return (sourceFile) => {
@@ -4348,16 +4423,16 @@ var NgCompiler = class _NgCompiler {
4348
4423
  return null;
4349
4424
  }
4350
4425
  const sourceFile = node.getSourceFile();
4351
- const printer = ts25.createPrinter();
4352
- const nodeText = printer.printNode(ts25.EmitHint.Unspecified, callback, sourceFile);
4353
- return ts25.transpileModule(nodeText, {
4426
+ const printer = ts26.createPrinter();
4427
+ const nodeText = printer.printNode(ts26.EmitHint.Unspecified, callback, sourceFile);
4428
+ return ts26.transpileModule(nodeText, {
4354
4429
  compilerOptions: {
4355
4430
  ...this.options,
4356
4431
  // Some module types can produce additional code (see #60795) whereas we need the
4357
4432
  // HMR update module to use a native `export`. Override the `target` and `module`
4358
4433
  // to ensure that it looks as expected.
4359
- module: ts25.ModuleKind.ES2022,
4360
- target: ts25.ScriptTarget.ES2022
4434
+ module: ts26.ModuleKind.ES2022,
4435
+ target: ts26.ScriptTarget.ES2022
4361
4436
  },
4362
4437
  fileName: sourceFile.fileName,
4363
4438
  reportDiagnostics: false
@@ -4733,18 +4808,18 @@ function isAngularCorePackage(program) {
4733
4808
  return false;
4734
4809
  }
4735
4810
  return r3Symbols.statements.some((stmt) => {
4736
- if (!ts25.isVariableStatement(stmt)) {
4811
+ if (!ts26.isVariableStatement(stmt)) {
4737
4812
  return false;
4738
4813
  }
4739
- const modifiers = ts25.getModifiers(stmt);
4740
- if (modifiers === void 0 || !modifiers.some((mod) => mod.kind === ts25.SyntaxKind.ExportKeyword)) {
4814
+ const modifiers = ts26.getModifiers(stmt);
4815
+ if (modifiers === void 0 || !modifiers.some((mod) => mod.kind === ts26.SyntaxKind.ExportKeyword)) {
4741
4816
  return false;
4742
4817
  }
4743
4818
  return stmt.declarationList.declarations.some((decl) => {
4744
- if (!ts25.isIdentifier(decl.name) || decl.name.text !== "ITS_JUST_ANGULAR") {
4819
+ if (!ts26.isIdentifier(decl.name) || decl.name.text !== "ITS_JUST_ANGULAR") {
4745
4820
  return false;
4746
4821
  }
4747
- if (decl.initializer === void 0 || decl.initializer.kind !== ts25.SyntaxKind.TrueKeyword) {
4822
+ if (decl.initializer === void 0 || decl.initializer.kind !== ts26.SyntaxKind.TrueKeyword) {
4748
4823
  return false;
4749
4824
  }
4750
4825
  return true;
@@ -4757,7 +4832,7 @@ function getR3SymbolsFile(program) {
4757
4832
  function* verifyCompatibleTypeCheckOptions(options) {
4758
4833
  if (options.fullTemplateTypeCheck === false && options.strictTemplates === true) {
4759
4834
  yield makeConfigDiagnostic({
4760
- category: ts25.DiagnosticCategory.Error,
4835
+ category: ts26.DiagnosticCategory.Error,
4761
4836
  code: ErrorCode.CONFIG_STRICT_TEMPLATES_IMPLIES_FULL_TEMPLATE_TYPECHECK,
4762
4837
  messageText: `
4763
4838
  Angular compiler option "strictTemplates" is enabled, however "fullTemplateTypeCheck" is disabled.
@@ -4776,7 +4851,7 @@ https://angular.dev/tools/cli/template-typecheck
4776
4851
  }
4777
4852
  if (options.extendedDiagnostics && options.strictTemplates === false) {
4778
4853
  yield makeConfigDiagnostic({
4779
- category: ts25.DiagnosticCategory.Error,
4854
+ category: ts26.DiagnosticCategory.Error,
4780
4855
  code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_IMPLIES_STRICT_TEMPLATES,
4781
4856
  messageText: `
4782
4857
  Angular compiler option "extendedDiagnostics" is configured, however "strictTemplates" is disabled.
@@ -4793,7 +4868,7 @@ One of the following actions is required:
4793
4868
  const defaultCategory = options.extendedDiagnostics?.defaultCategory;
4794
4869
  if (defaultCategory && !allowedCategoryLabels.includes(defaultCategory)) {
4795
4870
  yield makeConfigDiagnostic({
4796
- category: ts25.DiagnosticCategory.Error,
4871
+ category: ts26.DiagnosticCategory.Error,
4797
4872
  code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL,
4798
4873
  messageText: `
4799
4874
  Angular compiler option "extendedDiagnostics.defaultCategory" has an unknown diagnostic category: "${defaultCategory}".
@@ -4806,7 +4881,7 @@ ${allowedCategoryLabels.join("\n")}
4806
4881
  for (const [checkName, category] of Object.entries(options.extendedDiagnostics?.checks ?? {})) {
4807
4882
  if (!SUPPORTED_DIAGNOSTIC_NAMES.has(checkName)) {
4808
4883
  yield makeConfigDiagnostic({
4809
- category: ts25.DiagnosticCategory.Error,
4884
+ category: ts26.DiagnosticCategory.Error,
4810
4885
  code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CHECK,
4811
4886
  messageText: `
4812
4887
  Angular compiler option "extendedDiagnostics.checks" has an unknown check: "${checkName}".
@@ -4818,7 +4893,7 @@ ${Array.from(SUPPORTED_DIAGNOSTIC_NAMES).join("\n")}
4818
4893
  }
4819
4894
  if (!allowedCategoryLabels.includes(category)) {
4820
4895
  yield makeConfigDiagnostic({
4821
- category: ts25.DiagnosticCategory.Error,
4896
+ category: ts26.DiagnosticCategory.Error,
4822
4897
  code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL,
4823
4898
  messageText: `
4824
4899
  Angular compiler option "extendedDiagnostics.checks['${checkName}']" has an unknown diagnostic category: "${category}".
@@ -4849,7 +4924,7 @@ var ReferenceGraphAdapter = class {
4849
4924
  for (const { node } of references) {
4850
4925
  let sourceFile = node.getSourceFile();
4851
4926
  if (sourceFile === void 0) {
4852
- sourceFile = ts25.getOriginalNode(node).getSourceFile();
4927
+ sourceFile = ts26.getOriginalNode(node).getSourceFile();
4853
4928
  }
4854
4929
  if (sourceFile === void 0 || !isDtsPath(sourceFile.fileName)) {
4855
4930
  this.graph.add(source, node);
@@ -4890,7 +4965,7 @@ function versionMapFromProgram(program, driver) {
4890
4965
  }
4891
4966
 
4892
4967
  // packages/compiler-cli/src/ngtsc/core/src/host.js
4893
- import ts26 from "typescript";
4968
+ import ts27 from "typescript";
4894
4969
  var DelegatingCompilerHost = class {
4895
4970
  delegate;
4896
4971
  createHash;
@@ -5029,7 +5104,7 @@ var NgCompilerHost = class _NgCompilerHost extends DelegatingCompilerHost {
5029
5104
  entryPoint = findFlatIndexEntryPoint(normalizedTsInputFiles);
5030
5105
  if (entryPoint === null) {
5031
5106
  diagnostics.push({
5032
- category: ts26.DiagnosticCategory.Error,
5107
+ category: ts27.DiagnosticCategory.Error,
5033
5108
  code: ngErrorCode(ErrorCode.CONFIG_FLAT_MODULE_NO_INDEX),
5034
5109
  file: void 0,
5035
5110
  start: void 0,
@@ -5083,10 +5158,10 @@ var NgCompilerHost = class _NgCompilerHost extends DelegatingCompilerHost {
5083
5158
  return this.fileNameToModuleName !== void 0 ? this : null;
5084
5159
  }
5085
5160
  createCachedResolveModuleNamesFunction() {
5086
- const moduleResolutionCache = ts26.createModuleResolutionCache(this.getCurrentDirectory(), this.getCanonicalFileName.bind(this));
5161
+ const moduleResolutionCache = ts27.createModuleResolutionCache(this.getCurrentDirectory(), this.getCanonicalFileName.bind(this));
5087
5162
  return (moduleNames, containingFile, reusedNames, redirectedReference, options) => {
5088
5163
  return moduleNames.map((moduleName) => {
5089
- const module = ts26.resolveModuleName(moduleName, containingFile, options, this, moduleResolutionCache, redirectedReference);
5164
+ const module = ts27.resolveModuleName(moduleName, containingFile, options, this, moduleResolutionCache, redirectedReference);
5090
5165
  return module.resolvedModule;
5091
5166
  });
5092
5167
  };
@@ -5118,7 +5193,7 @@ var NgtscProgram = class {
5118
5193
  if (reuseProgram !== void 0) {
5119
5194
  retagAllTsFiles(reuseProgram);
5120
5195
  }
5121
- this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () => ts27.createProgram(this.host.inputFiles, options, this.host, reuseProgram));
5196
+ this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () => ts28.createProgram(this.host.inputFiles, options, this.host, reuseProgram));
5122
5197
  perfRecorder.phase(PerfPhase.Unaccounted);
5123
5198
  perfRecorder.memory(PerfCheckpoint.TypeScriptProgramCreate);
5124
5199
  this.host.postProgramCreationCleanup();
@@ -5347,16 +5422,16 @@ function createProgram({ rootNames, options, host, oldProgram }) {
5347
5422
  }
5348
5423
 
5349
5424
  // packages/compiler-cli/src/perform_compile.js
5350
- import ts29 from "typescript";
5425
+ import ts30 from "typescript";
5351
5426
 
5352
5427
  // packages/compiler-cli/src/transformers/util.js
5353
- import ts28 from "typescript";
5428
+ import ts29 from "typescript";
5354
5429
  function createMessageDiagnostic(messageText) {
5355
5430
  return {
5356
5431
  file: void 0,
5357
5432
  start: void 0,
5358
5433
  length: void 0,
5359
- category: ts28.DiagnosticCategory.Message,
5434
+ category: ts29.DiagnosticCategory.Message,
5360
5435
  messageText,
5361
5436
  code: DEFAULT_ERROR_CODE,
5362
5437
  source: SOURCE
@@ -5365,13 +5440,13 @@ function createMessageDiagnostic(messageText) {
5365
5440
 
5366
5441
  // packages/compiler-cli/src/perform_compile.js
5367
5442
  var defaultFormatHost = {
5368
- getCurrentDirectory: () => ts29.sys.getCurrentDirectory(),
5443
+ getCurrentDirectory: () => ts30.sys.getCurrentDirectory(),
5369
5444
  getCanonicalFileName: (fileName) => fileName,
5370
- getNewLine: () => ts29.sys.newLine
5445
+ getNewLine: () => ts30.sys.newLine
5371
5446
  };
5372
5447
  function formatDiagnostics(diags, host = defaultFormatHost) {
5373
5448
  if (diags && diags.length) {
5374
- return diags.map((diagnostic) => replaceTsWithNgInErrors(ts29.formatDiagnosticsWithColorAndContext([diagnostic], host))).join("");
5449
+ return diags.map((diagnostic) => replaceTsWithNgInErrors(ts30.formatDiagnosticsWithColorAndContext([diagnostic], host))).join("");
5375
5450
  } else {
5376
5451
  return "";
5377
5452
  }
@@ -5387,7 +5462,7 @@ function calcProjectFileAndBasePath(project, host = getFileSystem()) {
5387
5462
  function readConfiguration(project, existingOptions, host = getFileSystem()) {
5388
5463
  try {
5389
5464
  const fs = getFileSystem();
5390
- const readConfigFile = (configFile) => ts29.readConfigFile(configFile, (file) => host.readFile(host.resolve(file)));
5465
+ const readConfigFile = (configFile) => ts30.readConfigFile(configFile, (file) => host.readFile(host.resolve(file)));
5391
5466
  const readAngularCompilerOptions = (configFile, parentOptions = {}) => {
5392
5467
  const { config: config2, error: error2 } = readConfigFile(configFile);
5393
5468
  if (error2) {
@@ -5423,7 +5498,7 @@ function readConfiguration(project, existingOptions, host = getFileSystem()) {
5423
5498
  ...existingOptions
5424
5499
  };
5425
5500
  const parseConfigHost = createParseConfigHost(host, fs);
5426
- const { options, errors, fileNames: rootNames, projectReferences } = ts29.parseJsonConfigFileContent(config, parseConfigHost, basePath, existingCompilerOptions, configFileName);
5501
+ const { options, errors, fileNames: rootNames, projectReferences } = ts30.parseJsonConfigFileContent(config, parseConfigHost, basePath, existingCompilerOptions, configFileName);
5427
5502
  let emitFlags = EmitFlags.Default;
5428
5503
  if (!(options["skipMetadataEmit"] || options["flatModuleOutFile"])) {
5429
5504
  emitFlags |= EmitFlags.Metadata;
@@ -5435,7 +5510,7 @@ function readConfiguration(project, existingOptions, host = getFileSystem()) {
5435
5510
  } catch (e) {
5436
5511
  const errors = [
5437
5512
  {
5438
- category: ts29.DiagnosticCategory.Error,
5513
+ category: ts30.DiagnosticCategory.Error,
5439
5514
  messageText: e.stack ?? e.message,
5440
5515
  file: void 0,
5441
5516
  start: void 0,
@@ -5470,7 +5545,7 @@ function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
5470
5545
  }
5471
5546
  } else {
5472
5547
  const parseConfigHost = createParseConfigHost(host, fs);
5473
- const { resolvedModule } = ts29.nodeModuleNameResolver(extendsValue, configFile, { moduleResolution: ts29.ModuleResolutionKind.Node10, resolveJsonModule: true }, parseConfigHost);
5548
+ const { resolvedModule } = ts30.nodeModuleNameResolver(extendsValue, configFile, { moduleResolution: ts30.ModuleResolutionKind.Node10, resolveJsonModule: true }, parseConfigHost);
5474
5549
  if (resolvedModule) {
5475
5550
  return absoluteFrom(resolvedModule.resolvedFileName);
5476
5551
  }
@@ -5480,7 +5555,7 @@ function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
5480
5555
  function exitCodeFromResult(diags) {
5481
5556
  if (!diags)
5482
5557
  return 0;
5483
- if (diags.every((diag) => diag.category !== ts29.DiagnosticCategory.Error)) {
5558
+ if (diags.every((diag) => diag.category !== ts30.DiagnosticCategory.Error)) {
5484
5559
  return 0;
5485
5560
  }
5486
5561
  return diags.some((d) => d.source === "angular" && d.code === UNKNOWN_ERROR_CODE) ? 2 : 1;
@@ -5518,7 +5593,7 @@ function performCompilation({ rootNames, options, host, oldProgram, emitCallback
5518
5593
  } catch (e) {
5519
5594
  program = void 0;
5520
5595
  allDiagnostics.push({
5521
- category: ts29.DiagnosticCategory.Error,
5596
+ category: ts30.DiagnosticCategory.Error,
5522
5597
  messageText: e.stack ?? e.message,
5523
5598
  code: UNKNOWN_ERROR_CODE,
5524
5599
  file: void 0,
@@ -5548,7 +5623,7 @@ function defaultGatherDiagnostics(program) {
5548
5623
  return allDiagnostics;
5549
5624
  }
5550
5625
  function hasErrors(diags) {
5551
- return diags.some((d) => d.category === ts29.DiagnosticCategory.Error);
5626
+ return diags.some((d) => d.category === ts30.DiagnosticCategory.Error);
5552
5627
  }
5553
5628
 
5554
5629
  export {
@@ -12,7 +12,7 @@ import {
12
12
  formatDiagnostics,
13
13
  performCompilation,
14
14
  readConfiguration
15
- } from "./chunk-ES5JHT4S.js";
15
+ } from "./chunk-6MT4TMWB.js";
16
16
 
17
17
  // packages/compiler-cli/src/main.js
18
18
  import ts2 from "typescript";
@@ -455,7 +455,7 @@ import { compileDirectiveFromMetadata, makeBindingParser, ParseLocation, ParseSo
455
455
  // packages/compiler-cli/linker/src/file_linker/partial_linkers/util.js
456
456
  import { createMayBeForwardRefExpression, outputAst as o2 } from "@angular/compiler";
457
457
  import semver from "semver";
458
- var PLACEHOLDER_VERSION = "20.3.0";
458
+ var PLACEHOLDER_VERSION = "20.3.2";
459
459
  function wrapReference(wrapped) {
460
460
  return { value: wrapped, type: wrapped };
461
461
  }
package/bundles/index.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  isTsDiagnostic,
29
29
  performCompilation,
30
30
  readConfiguration
31
- } from "./chunk-ES5JHT4S.js";
31
+ } from "./chunk-6MT4TMWB.js";
32
32
  import {
33
33
  ConsoleLogger,
34
34
  LogLevel
@@ -37,7 +37,7 @@ import {
37
37
  angularJitApplicationTransform,
38
38
  getDownlevelDecoratorsTransform,
39
39
  getInitializerApiJitTransform
40
- } from "./chunk-6DF2AWLX.js";
40
+ } from "./chunk-5YTDMIWM.js";
41
41
  import {
42
42
  ActivePerfRecorder,
43
43
  ErrorCode,
@@ -46,7 +46,7 @@ import {
46
46
  TsCreateProgramDriver,
47
47
  isLocalCompilationDiagnostics,
48
48
  ngErrorCode
49
- } from "./chunk-PVSLT73R.js";
49
+ } from "./chunk-2JGGVEXA.js";
50
50
  import "./chunk-I2BHWRAU.js";
51
51
  import {
52
52
  InvalidFileSystem,
@@ -77,7 +77,7 @@ import "./chunk-G7GFT6BU.js";
77
77
 
78
78
  // packages/compiler-cli/src/version.js
79
79
  import { Version } from "@angular/compiler";
80
- var VERSION = new Version("20.3.0");
80
+ var VERSION = new Version("20.3.2");
81
81
 
82
82
  // packages/compiler-cli/private/tooling.js
83
83
  var GLOBAL_DEFS_FOR_TERSER = {
@@ -13,7 +13,7 @@ import {
13
13
  TypeScriptReflectionHost,
14
14
  createForwardRefResolver,
15
15
  reflectObjectLiteral
16
- } from "../chunk-PVSLT73R.js";
16
+ } from "../chunk-2JGGVEXA.js";
17
17
  import "../chunk-I2BHWRAU.js";
18
18
  import "../chunk-GWZQLAGK.js";
19
19
  import "../chunk-XYYEESKY.js";
@@ -4,8 +4,8 @@
4
4
 
5
5
  import {
6
6
  angularJitApplicationTransform
7
- } from "../chunk-6DF2AWLX.js";
8
- import "../chunk-PVSLT73R.js";
7
+ } from "../chunk-5YTDMIWM.js";
8
+ import "../chunk-2JGGVEXA.js";
9
9
  import "../chunk-I2BHWRAU.js";
10
10
  import "../chunk-GWZQLAGK.js";
11
11
  import "../chunk-XYYEESKY.js";
@@ -6,12 +6,12 @@
6
6
  import {
7
7
  main,
8
8
  readCommandLineAndConfiguration
9
- } from "../../chunk-OLESUCWZ.js";
9
+ } from "../../chunk-BIXQTG65.js";
10
10
  import {
11
11
  EmitFlags
12
- } from "../../chunk-ES5JHT4S.js";
13
- import "../../chunk-6DF2AWLX.js";
14
- import "../../chunk-PVSLT73R.js";
12
+ } from "../../chunk-6MT4TMWB.js";
13
+ import "../../chunk-5YTDMIWM.js";
14
+ import "../../chunk-2JGGVEXA.js";
15
15
  import "../../chunk-I2BHWRAU.js";
16
16
  import {
17
17
  setFileSystem
@@ -5,10 +5,10 @@
5
5
 
6
6
  import {
7
7
  main
8
- } from "../../chunk-OLESUCWZ.js";
9
- import "../../chunk-ES5JHT4S.js";
10
- import "../../chunk-6DF2AWLX.js";
11
- import "../../chunk-PVSLT73R.js";
8
+ } from "../../chunk-BIXQTG65.js";
9
+ import "../../chunk-6MT4TMWB.js";
10
+ import "../../chunk-5YTDMIWM.js";
11
+ import "../../chunk-2JGGVEXA.js";
12
12
  import "../../chunk-I2BHWRAU.js";
13
13
  import {
14
14
  setFileSystem
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { MaybeForwardRefExpression, outputAst as o, R3DeclareDependencyMetadata, R3DependencyMetadata, R3Reference } from '@angular/compiler';
9
9
  import { AstObject, AstValue } from '../../ast/ast_value';
10
- export declare const PLACEHOLDER_VERSION = "20.3.0";
10
+ export declare const PLACEHOLDER_VERSION = "20.3.2";
11
11
  export declare function wrapReference<TExpression>(wrapped: o.WrappedNodeExpr<TExpression>): R3Reference;
12
12
  /**
13
13
  * Parses the value of an enum from the AST value's symbol name.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/compiler-cli",
3
- "version": "20.3.0",
3
+ "version": "20.3.2",
4
4
  "description": "Angular - the compiler CLI for Node.js",
5
5
  "typings": "index.d.ts",
6
6
  "bin": {
@@ -48,7 +48,7 @@
48
48
  "yargs": "^18.0.0"
49
49
  },
50
50
  "peerDependencies": {
51
- "@angular/compiler": "20.3.0",
51
+ "@angular/compiler": "20.3.2",
52
52
  "typescript": ">=5.8 <6.0"
53
53
  },
54
54
  "peerDependenciesMeta": {
@@ -9,7 +9,7 @@ import { LegacyAnimationTriggerNames, DeclarationListEmitMode, DeferBlockDepsEmi
9
9
  import ts from 'typescript';
10
10
  import { Reference } from '../../../imports';
11
11
  import { ClassPropertyMapping, DirectiveResources, DirectiveTypeCheckMeta, HostDirectiveMeta, InputMapping } from '../../../metadata';
12
- import { ClassDeclaration } from '../../../reflection';
12
+ import { ClassDeclaration, Import } from '../../../reflection';
13
13
  import { SubsetOfKeys } from '../../../util/src/typescript';
14
14
  import { ParsedTemplateWithSource, StyleUrlMeta } from './resources';
15
15
  import { HostBindingNodes } from '../../directive';
@@ -84,10 +84,11 @@ export interface ComponentResolutionData {
84
84
  declarationListEmitMode: DeclarationListEmitMode;
85
85
  /**
86
86
  * Map of all types that can be defer loaded (ts.ClassDeclaration) ->
87
- * corresponding import declaration (ts.ImportDeclaration) within
88
- * the current source file.
87
+ * corresponding import information (reflection `Import`) within
88
+ * the current source file. The `Import` preserves the exported name
89
+ * as seen by the importing module so aliasing is handled correctly.
89
90
  */
90
- deferrableDeclToImportDecl: Map<ClassDeclaration, ts.ImportDeclaration>;
91
+ deferrableDeclToImportDecl: Map<ClassDeclaration, Import>;
91
92
  /**
92
93
  * Map of `@defer` blocks -> their corresponding dependencies.
93
94
  * Required to compile the defer resolver function in `PerBlock` mode.
@@ -525,6 +525,21 @@ export declare enum ErrorCode {
525
525
  * ```
526
526
  */
527
527
  UNINVOKED_FUNCTION_IN_TEXT_INTERPOLATION = 8117,
528
+ /**
529
+ * A required initializer is being invoked in a forbidden context such as a property initializer
530
+ * or a constructor.
531
+ *
532
+ * For example:
533
+ * ```ts
534
+ * class MyComponent {
535
+ * myInput = input.required();
536
+ * somValue = this.myInput(); // Error
537
+ *
538
+ * constructor() {
539
+ * this.myInput(); // Error
540
+ * }
541
+ */
542
+ FORBIDDEN_REQUIRED_INITIALIZER_INVOCATION = 8118,
528
543
  /**
529
544
  * The template type-checking engine would need to generate an inline type check block for a
530
545
  * component, but the current type-checking environment doesn't support it.
@@ -12,4 +12,4 @@
12
12
  * - packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.ts
13
13
  * - packages/core/src/error_details_base_url.ts
14
14
  */
15
- export declare const ERROR_DETAILS_PAGE_BASE_URL = "https://angular.dev/errors";
15
+ export declare const ERROR_DETAILS_PAGE_BASE_URL: string;
@@ -0,0 +1,22 @@
1
+ /*!
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import ts from 'typescript';
9
+ import { ImportedSymbolsTracker } from '../../../imports';
10
+ import { ReflectionHost } from '../../../reflection';
11
+ import { SourceFileValidatorRule } from './api';
12
+ /**
13
+ * Rule that flags forbidden invocations of required initializers in property initializers and constructors.
14
+ */
15
+ export declare class ForbiddenRequiredInitializersInvocationRule implements SourceFileValidatorRule {
16
+ private reflector;
17
+ private importedSymbolsTracker;
18
+ constructor(reflector: ReflectionHost, importedSymbolsTracker: ImportedSymbolsTracker);
19
+ shouldCheck(sourceFile: ts.SourceFile): boolean;
20
+ checkNode(node: ts.Node): ts.Diagnostic[] | null;
21
+ private isPropDeclarationARequiredInitializer;
22
+ }