@angular/compiler-cli 21.1.0-next.4 → 21.1.0

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.
@@ -8,7 +8,7 @@ import {
8
8
  TrackedIncrementalBuildStrategy,
9
9
  freshCompilationTicket,
10
10
  incrementalFromCompilerTicket
11
- } from "./chunk-6VDGFZBQ.js";
11
+ } from "./chunk-EWMF72RR.js";
12
12
  import {
13
13
  ActivePerfRecorder,
14
14
  OptimizeFor,
@@ -18,7 +18,7 @@ import {
18
18
  TsCreateProgramDriver,
19
19
  replaceTsWithNgInErrors,
20
20
  retagAllTsFiles
21
- } from "./chunk-PUEBQK4X.js";
21
+ } from "./chunk-TTZRVNVM.js";
22
22
  import {
23
23
  absoluteFrom,
24
24
  createFileSystemTsReadDirectoryFn,
@@ -12,7 +12,7 @@ import {
12
12
  formatDiagnostics,
13
13
  performCompilation,
14
14
  readConfiguration
15
- } from "./chunk-ML6J2RBK.js";
15
+ } from "./chunk-ATAZXXPH.js";
16
16
 
17
17
  // packages/compiler-cli/src/main.js
18
18
  import ts2 from "typescript";
@@ -13,6 +13,7 @@ import {
13
13
  CompoundComponentScopeReader,
14
14
  CompoundMetadataReader,
15
15
  CompoundMetadataRegistry,
16
+ DOC_PAGE_BASE_URL,
16
17
  DefaultImportTracker,
17
18
  DeferredSymbolTracker,
18
19
  DelegatingPerfRecorder,
@@ -87,7 +88,7 @@ import {
87
88
  toUnredirectedSourceFile,
88
89
  tryParseInitializerApi,
89
90
  untagAllTsFiles
90
- } from "./chunk-PUEBQK4X.js";
91
+ } from "./chunk-TTZRVNVM.js";
91
92
  import {
92
93
  LogicalFileSystem,
93
94
  absoluteFromSourceFile,
@@ -622,12 +623,15 @@ var DirectiveExtractor = class extends ClassExtractor {
622
623
  }
623
624
  /** Extract docs info for directives and components (including underlying class info). */
624
625
  extract() {
626
+ const selector = this.metadata.selector ?? "";
627
+ const aliases = extractAliasesFromSelector(selector);
625
628
  return {
626
629
  ...super.extract(),
627
630
  isStandalone: this.metadata.isStandalone,
628
- selector: this.metadata.selector ?? "",
631
+ selector,
629
632
  exportAs: this.metadata.exportAs ?? [],
630
- entryType: this.metadata.isComponent ? EntryType.Component : EntryType.Directive
633
+ entryType: this.metadata.isComponent ? EntryType.Component : EntryType.Directive,
634
+ ...aliases.length > 0 && { aliases }
631
635
  };
632
636
  }
633
637
  /** Extracts docs info for a directive property, including input/output metadata. */
@@ -717,6 +721,21 @@ function extractPipeSyntax(metadata, classDeclaration) {
717
721
  });
718
722
  return `{{ value_expression | ${metadata.name}${paramNames.length ? ":" + paramNames.join(":") : ""} }}`;
719
723
  }
724
+ function extractAliasesFromSelector(selector) {
725
+ if (!selector) {
726
+ return [];
727
+ }
728
+ const aliases = [];
729
+ const attributeRegex = /\[([^\]=]+)(?:=[^\]]+)?\]/g;
730
+ let match;
731
+ while ((match = attributeRegex.exec(selector)) !== null) {
732
+ const attributeName = match[1].trim();
733
+ if (attributeName) {
734
+ aliases.push(attributeName);
735
+ }
736
+ }
737
+ return aliases;
738
+ }
720
739
 
721
740
  // packages/compiler-cli/src/ngtsc/docs/src/constant_extractor.js
722
741
  import ts7 from "typescript";
@@ -1204,7 +1223,7 @@ var DocsExtractor = class {
1204
1223
  if (isAngularPrivateName(exportName)) {
1205
1224
  continue;
1206
1225
  }
1207
- const entry = this.extractDeclarations(exportName, declarations);
1226
+ const entry = this.extractDeclarations(declarations);
1208
1227
  if (entry && !isIgnoredDocEntry(entry)) {
1209
1228
  const realSourceFile = declarations[0].getSourceFile();
1210
1229
  const importedSymbols = getImportedSymbols(realSourceFile);
@@ -1233,7 +1252,7 @@ var DocsExtractor = class {
1233
1252
  * the same name. This is used to combine entries, e.g. for a type and a namespace that are
1234
1253
  * exported under the same name.
1235
1254
  */
1236
- extractDeclarations(exportName, nodes) {
1255
+ extractDeclarations(nodes) {
1237
1256
  const entries = nodes.map((node) => this.extractDeclaration(node));
1238
1257
  const decorator = entries.find((e) => e?.entryType === EntryType.Decorator);
1239
1258
  if (decorator) {
@@ -2138,7 +2157,7 @@ var IndexingContext = class {
2138
2157
  import { ParseSourceFile } from "@angular/compiler";
2139
2158
 
2140
2159
  // packages/compiler-cli/src/ngtsc/indexer/src/template.js
2141
- import { ASTWithSource, CombinedRecursiveAstVisitor, ImplicitReceiver, PropertyRead, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstReference, TmplAstTemplate, TmplAstVariable, tmplAstVisitAll } from "@angular/compiler";
2160
+ import { ASTWithSource, CombinedRecursiveAstVisitor, ImplicitReceiver, PropertyRead, ThisReceiver, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstReference, TmplAstTemplate, TmplAstVariable, tmplAstVisitAll } from "@angular/compiler";
2142
2161
  var TemplateVisitor = class extends CombinedRecursiveAstVisitor {
2143
2162
  boundTemplate;
2144
2163
  // Identifiers of interest found in the template.
@@ -2368,7 +2387,7 @@ var TemplateVisitor = class extends CombinedRecursiveAstVisitor {
2368
2387
  if (this.currentAstWithSource === null || this.currentAstWithSource.source === null) {
2369
2388
  return;
2370
2389
  }
2371
- if (!(ast.receiver instanceof ImplicitReceiver)) {
2390
+ if (!(ast.receiver instanceof ImplicitReceiver) && !(ast.receiver instanceof ThisReceiver)) {
2372
2391
  return;
2373
2392
  }
2374
2393
  const { absoluteOffset, source: expressionStr } = this.currentAstWithSource;
@@ -3024,7 +3043,7 @@ var InvalidBananaInBoxCheck = class extends TemplateCheckWithVisitor {
3024
3043
  const boundSyntax = node.sourceSpan.toString();
3025
3044
  const expectedBoundSyntax = boundSyntax.replace(`(${name})`, `[(${name.slice(1, -1)})]`);
3026
3045
  const diagnostic = ctx.makeTemplateDiagnostic(node.sourceSpan, `In the two-way binding syntax the parentheses should be inside the brackets, ex. '${expectedBoundSyntax}'.
3027
- Find more at https://angular.dev/guide/templates/two-way-binding`);
3046
+ Find more at ${DOC_PAGE_BASE_URL}/guide/templates/two-way-binding`);
3028
3047
  return [diagnostic];
3029
3048
  }
3030
3049
  };
@@ -3664,7 +3683,7 @@ var SUPPORTED_DIAGNOSTIC_NAMES = /* @__PURE__ */ new Set([
3664
3683
  ]);
3665
3684
 
3666
3685
  // packages/compiler-cli/src/ngtsc/typecheck/template_semantics/src/template_semantics_checker.js
3667
- 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";
3686
+ 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, ThisReceiver as ThisReceiver2 } from "@angular/compiler";
3668
3687
  import ts23 from "typescript";
3669
3688
  var TemplateSemanticsCheckerImpl = class {
3670
3689
  templateTypeChecker;
@@ -3716,7 +3735,7 @@ var ExpressionsSemanticsVisitor = class extends RecursiveAstVisitor {
3716
3735
  this.checkForIllegalWriteInTwoWayBinding(ast, context);
3717
3736
  }
3718
3737
  checkForIllegalWriteInEventBinding(ast, context) {
3719
- if (!(context instanceof TmplAstBoundEvent3) || !(ast.receiver instanceof ImplicitReceiver2)) {
3738
+ if (!this.shouldCheckForIllegalWrites(ast, context)) {
3720
3739
  return;
3721
3740
  }
3722
3741
  const target = this.templateTypeChecker.getExpressionTarget(ast, this.component);
@@ -3726,7 +3745,7 @@ var ExpressionsSemanticsVisitor = class extends RecursiveAstVisitor {
3726
3745
  }
3727
3746
  }
3728
3747
  checkForIllegalWriteInTwoWayBinding(ast, context) {
3729
- if (!(context instanceof TmplAstBoundEvent3) || context.type !== ParsedEventType2.TwoWay || !(ast.receiver instanceof ImplicitReceiver2) || ast !== unwrapAstWithSource(context.handler)) {
3748
+ if (!this.shouldCheckForIllegalWrites(ast, context) || context.type !== ParsedEventType2.TwoWay || ast !== unwrapAstWithSource(context.handler)) {
3730
3749
  return;
3731
3750
  }
3732
3751
  const target = this.templateTypeChecker.getExpressionTarget(ast, this.component);
@@ -3757,6 +3776,9 @@ var ExpressionsSemanticsVisitor = class extends RecursiveAstVisitor {
3757
3776
  }
3758
3777
  ]);
3759
3778
  }
3779
+ shouldCheckForIllegalWrites(ast, context) {
3780
+ return context instanceof TmplAstBoundEvent3 && (ast.receiver instanceof ImplicitReceiver2 || ast.receiver instanceof ThisReceiver2);
3781
+ }
3760
3782
  };
3761
3783
  function unwrapAstWithSource(ast) {
3762
3784
  return ast instanceof ASTWithSource5 ? ast.ast : ast;
@@ -4944,7 +4966,7 @@ One of the following actions is required:
4944
4966
  2. Remove "strictTemplates" or set it to 'false'.
4945
4967
 
4946
4968
  More information about the template type checking compiler options can be found in the documentation:
4947
- https://angular.dev/tools/cli/template-typecheck
4969
+ ${DOC_PAGE_BASE_URL}/tools/cli/template-typecheck
4948
4970
  `.trim()
4949
4971
  });
4950
4972
  }
@@ -214,10 +214,14 @@ var ExpressionTranslatorVisitor = class {
214
214
  }
215
215
  visitLiteralMapExpr(ast, context) {
216
216
  const properties = ast.entries.map((entry) => {
217
- return {
217
+ return entry instanceof o.LiteralMapPropertyAssignment ? {
218
+ kind: "property",
218
219
  propertyName: entry.key,
219
220
  quoted: entry.quoted,
220
221
  value: entry.value.visitExpression(this, context)
222
+ } : {
223
+ kind: "spread",
224
+ expression: entry.expression.visitExpression(this, context)
221
225
  };
222
226
  });
223
227
  return this.setSourceMapRange(this.factory.createObjectLiteral(properties), ast.sourceSpan);
@@ -228,6 +232,10 @@ var ExpressionTranslatorVisitor = class {
228
232
  visitTemplateLiteralElementExpr(ast, context) {
229
233
  throw new Error("Method not implemented");
230
234
  }
235
+ visitSpreadElementExpr(ast, context) {
236
+ const expression = ast.expression.visitExpression(this, context);
237
+ return this.setSourceMapRange(this.factory.createSpreadElement(expression), ast.sourceSpan);
238
+ }
231
239
  visitWrappedNodeExpr(ast, _context) {
232
240
  this.recordWrappedNode(ast);
233
241
  return ast.node;