@angular/compiler-cli 17.0.1 → 17.0.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.
@@ -2990,11 +2990,15 @@ function tsCreateElement(tagName) {
2990
2990
  );
2991
2991
  }
2992
2992
  function tsDeclareVariable(id, type) {
2993
+ let initializer = ts19.factory.createNonNullExpression(ts19.factory.createNull());
2994
+ if (type.kind === ts19.SyntaxKind.BooleanKeyword) {
2995
+ initializer = ts19.factory.createAsExpression(initializer, ts19.factory.createKeywordTypeNode(ts19.SyntaxKind.BooleanKeyword));
2996
+ }
2993
2997
  const decl = ts19.factory.createVariableDeclaration(
2994
2998
  id,
2995
2999
  void 0,
2996
3000
  type,
2997
- ts19.factory.createNonNullExpression(ts19.factory.createNull())
3001
+ initializer
2998
3002
  );
2999
3003
  return ts19.factory.createVariableStatement(
3000
3004
  void 0,
@@ -4796,7 +4800,7 @@ var Context = class {
4796
4800
  return this.pipes.get(name);
4797
4801
  }
4798
4802
  };
4799
- var Scope = class {
4803
+ var _Scope = class {
4800
4804
  constructor(tcb, parent = null, guard = null) {
4801
4805
  this.tcb = tcb;
4802
4806
  this.parent = parent;
@@ -4810,7 +4814,7 @@ var Scope = class {
4810
4814
  this.statements = [];
4811
4815
  }
4812
4816
  static forNodes(tcb, parentScope, scopedNode, children, guard) {
4813
- const scope = new Scope(tcb, parentScope, guard);
4817
+ const scope = new _Scope(tcb, parentScope, guard);
4814
4818
  if (parentScope === null && tcb.env.config.enableTemplateTypeChecker) {
4815
4819
  scope.opQueue.push(new TcbComponentContextCompletionOp(scope));
4816
4820
  }
@@ -4832,8 +4836,11 @@ var Scope = class {
4832
4836
  }
4833
4837
  } else if (scopedNode instanceof TmplAstForLoopBlock) {
4834
4838
  this.registerVariable(scope, scopedNode.item, new TcbBlockVariableOp(tcb, scope, ts28.factory.createIdentifier(scopedNode.item.name), scopedNode.item));
4835
- for (const variable of Object.values(scopedNode.contextVariables)) {
4836
- const type = ts28.factory.createKeywordTypeNode(ts28.SyntaxKind.NumberKeyword);
4839
+ for (const [name, variable] of Object.entries(scopedNode.contextVariables)) {
4840
+ if (!this.forLoopContextVariableTypes.has(name)) {
4841
+ throw new Error(`Unrecognized for loop context variable ${name}`);
4842
+ }
4843
+ const type = ts28.factory.createKeywordTypeNode(this.forLoopContextVariableTypes.get(name));
4837
4844
  this.registerVariable(scope, variable, new TcbBlockImplicitVariableOp(tcb, scope, type, variable));
4838
4845
  }
4839
4846
  }
@@ -5110,6 +5117,17 @@ var Scope = class {
5110
5117
  }
5111
5118
  }
5112
5119
  };
5120
+ var Scope = _Scope;
5121
+ (() => {
5122
+ _Scope.forLoopContextVariableTypes = /* @__PURE__ */ new Map([
5123
+ ["$first", ts28.SyntaxKind.BooleanKeyword],
5124
+ ["$last", ts28.SyntaxKind.BooleanKeyword],
5125
+ ["$even", ts28.SyntaxKind.BooleanKeyword],
5126
+ ["$odd", ts28.SyntaxKind.BooleanKeyword],
5127
+ ["$index", ts28.SyntaxKind.NumberKeyword],
5128
+ ["$count", ts28.SyntaxKind.NumberKeyword]
5129
+ ]);
5130
+ })();
5113
5131
  function tcbThisParam(name, typeArguments) {
5114
5132
  return ts28.factory.createParameterDeclaration(
5115
5133
  void 0,
@@ -6899,8 +6917,8 @@ var SingleShimTypeCheckingHost = class extends SingleFileTypeCheckingHost {
6899
6917
  }
6900
6918
  };
6901
6919
 
6902
- // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/invalid_banana_in_box/index.mjs
6903
- import { TmplAstBoundEvent as TmplAstBoundEvent2 } from "@angular/compiler";
6920
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/interpolated_signal_not_invoked/index.mjs
6921
+ import { Interpolation, PropertyRead as PropertyRead6 } from "@angular/compiler";
6904
6922
 
6905
6923
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/api/api.mjs
6906
6924
  import { ASTWithSource as ASTWithSource4, RecursiveAstVisitor as RecursiveAstVisitor3, TmplAstBoundDeferredTrigger as TmplAstBoundDeferredTrigger2 } from "@angular/compiler";
@@ -7026,7 +7044,43 @@ var TemplateVisitor2 = class extends RecursiveAstVisitor3 {
7026
7044
  }
7027
7045
  };
7028
7046
 
7047
+ // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/interpolated_signal_not_invoked/index.mjs
7048
+ var InterpolatedSignalCheck = class extends TemplateCheckWithVisitor {
7049
+ constructor() {
7050
+ super(...arguments);
7051
+ this.code = ErrorCode.INTERPOLATED_SIGNAL_NOT_INVOKED;
7052
+ }
7053
+ visitNode(ctx, component, node) {
7054
+ if (node instanceof Interpolation) {
7055
+ return node.expressions.filter((item) => item instanceof PropertyRead6).flatMap((item) => {
7056
+ if (item instanceof PropertyRead6) {
7057
+ return buildDiagnosticForSignal(ctx, item, component);
7058
+ }
7059
+ return [];
7060
+ });
7061
+ }
7062
+ return [];
7063
+ }
7064
+ };
7065
+ function buildDiagnosticForSignal(ctx, node, component) {
7066
+ var _a, _b;
7067
+ const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
7068
+ if ((symbol == null ? void 0 : symbol.kind) === SymbolKind.Expression && (((_a = symbol.tsType.symbol) == null ? void 0 : _a.escapedName) === "WritableSignal" || ((_b = symbol.tsType.symbol) == null ? void 0 : _b.escapedName) === "Signal") && symbol.tsType.symbol.parent.escapedName.includes("@angular/core")) {
7069
+ const templateMapping = ctx.templateTypeChecker.getTemplateMappingAtTcbLocation(symbol.tcbLocation);
7070
+ const errorString = `${node.name} is a function and should be invoked: ${node.name}()`;
7071
+ const diagnostic = ctx.makeTemplateDiagnostic(templateMapping.span, errorString);
7072
+ return [diagnostic];
7073
+ }
7074
+ return [];
7075
+ }
7076
+ var factory = {
7077
+ code: ErrorCode.INTERPOLATED_SIGNAL_NOT_INVOKED,
7078
+ name: ExtendedTemplateDiagnosticName.INTERPOLATED_SIGNAL_NOT_INVOKED,
7079
+ create: () => new InterpolatedSignalCheck()
7080
+ };
7081
+
7029
7082
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/invalid_banana_in_box/index.mjs
7083
+ import { TmplAstBoundEvent as TmplAstBoundEvent2 } from "@angular/compiler";
7030
7084
  var InvalidBananaInBoxCheck = class extends TemplateCheckWithVisitor {
7031
7085
  constructor() {
7032
7086
  super(...arguments);
@@ -7045,7 +7099,7 @@ var InvalidBananaInBoxCheck = class extends TemplateCheckWithVisitor {
7045
7099
  return [diagnostic];
7046
7100
  }
7047
7101
  };
7048
- var factory = {
7102
+ var factory2 = {
7049
7103
  code: ErrorCode.INVALID_BANANA_IN_BOX,
7050
7104
  name: ExtendedTemplateDiagnosticName.INVALID_BANANA_IN_BOX,
7051
7105
  create: () => new InvalidBananaInBoxCheck()
@@ -7088,7 +7142,7 @@ var MissingControlFlowDirectiveCheck = class extends TemplateCheckWithVisitor {
7088
7142
  return [diagnostic];
7089
7143
  }
7090
7144
  };
7091
- var factory2 = {
7145
+ var factory3 = {
7092
7146
  code: ErrorCode.MISSING_CONTROL_FLOW_DIRECTIVE,
7093
7147
  name: ExtendedTemplateDiagnosticName.MISSING_CONTROL_FLOW_DIRECTIVE,
7094
7148
  create: (options) => {
@@ -7123,7 +7177,7 @@ var MissingNgForOfLetCheck = class extends TemplateCheckWithVisitor {
7123
7177
  return [diagnostic];
7124
7178
  }
7125
7179
  };
7126
- var factory3 = {
7180
+ var factory4 = {
7127
7181
  code: ErrorCode.MISSING_NGFOROF_LET,
7128
7182
  name: ExtendedTemplateDiagnosticName.MISSING_NGFOROF_LET,
7129
7183
  create: () => new MissingNgForOfLetCheck()
@@ -7162,7 +7216,7 @@ var NullishCoalescingNotNullableCheck = class extends TemplateCheckWithVisitor {
7162
7216
  return [diagnostic];
7163
7217
  }
7164
7218
  };
7165
- var factory4 = {
7219
+ var factory5 = {
7166
7220
  code: ErrorCode.NULLISH_COALESCING_NOT_NULLABLE,
7167
7221
  name: ExtendedTemplateDiagnosticName.NULLISH_COALESCING_NOT_NULLABLE,
7168
7222
  create: (options) => {
@@ -7208,7 +7262,7 @@ var OptionalChainNotNullableCheck = class extends TemplateCheckWithVisitor {
7208
7262
  return [diagnostic];
7209
7263
  }
7210
7264
  };
7211
- var factory5 = {
7265
+ var factory6 = {
7212
7266
  code: ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE,
7213
7267
  name: ExtendedTemplateDiagnosticName.OPTIONAL_CHAIN_NOT_NULLABLE,
7214
7268
  create: (options) => {
@@ -7238,7 +7292,7 @@ var SuffixNotSupportedCheck = class extends TemplateCheckWithVisitor {
7238
7292
  return [diagnostic];
7239
7293
  }
7240
7294
  };
7241
- var factory6 = {
7295
+ var factory7 = {
7242
7296
  code: ErrorCode.SUFFIX_NOT_SUPPORTED,
7243
7297
  name: ExtendedTemplateDiagnosticName.SUFFIX_NOT_SUPPORTED,
7244
7298
  create: () => new SuffixNotSupportedCheck()
@@ -7277,7 +7331,7 @@ var TextAttributeNotBindingSpec = class extends TemplateCheckWithVisitor {
7277
7331
  return [diagnostic];
7278
7332
  }
7279
7333
  };
7280
- var factory7 = {
7334
+ var factory8 = {
7281
7335
  code: ErrorCode.TEXT_ATTRIBUTE_NOT_BINDING,
7282
7336
  name: ExtendedTemplateDiagnosticName.TEXT_ATTRIBUTE_NOT_BINDING,
7283
7337
  create: () => new TextAttributeNotBindingSpec()
@@ -7300,12 +7354,12 @@ var ExtendedTemplateCheckerImpl = class {
7300
7354
  var _a, _b, _c, _d, _e;
7301
7355
  this.partialCtx = { templateTypeChecker, typeChecker };
7302
7356
  this.templateChecks = /* @__PURE__ */ new Map();
7303
- for (const factory8 of templateCheckFactories) {
7304
- const category = diagnosticLabelToCategory((_e = (_d = (_b = (_a = options == null ? void 0 : options.extendedDiagnostics) == null ? void 0 : _a.checks) == null ? void 0 : _b[factory8.name]) != null ? _d : (_c = options == null ? void 0 : options.extendedDiagnostics) == null ? void 0 : _c.defaultCategory) != null ? _e : DiagnosticCategoryLabel.Warning);
7357
+ for (const factory9 of templateCheckFactories) {
7358
+ const category = diagnosticLabelToCategory((_e = (_d = (_b = (_a = options == null ? void 0 : options.extendedDiagnostics) == null ? void 0 : _a.checks) == null ? void 0 : _b[factory9.name]) != null ? _d : (_c = options == null ? void 0 : options.extendedDiagnostics) == null ? void 0 : _c.defaultCategory) != null ? _e : DiagnosticCategoryLabel.Warning);
7305
7359
  if (category === null) {
7306
7360
  continue;
7307
7361
  }
7308
- const check = factory8.create(options);
7362
+ const check = factory9.create(options);
7309
7363
  if (check === null) {
7310
7364
  continue;
7311
7365
  }
@@ -7349,13 +7403,14 @@ ${value}`);
7349
7403
 
7350
7404
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/extended/index.mjs
7351
7405
  var ALL_DIAGNOSTIC_FACTORIES = [
7352
- factory,
7353
- factory4,
7354
- factory5,
7355
7406
  factory2,
7356
- factory7,
7407
+ factory5,
7408
+ factory6,
7357
7409
  factory3,
7358
- factory6
7410
+ factory8,
7411
+ factory4,
7412
+ factory7,
7413
+ factory
7359
7414
  ];
7360
7415
 
7361
7416
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/core/src/compiler.mjs
@@ -8034,7 +8089,7 @@ ${allowedCategoryLabels.join("\n")}
8034
8089
  `.trim()
8035
8090
  });
8036
8091
  }
8037
- const allExtendedDiagnosticNames = ALL_DIAGNOSTIC_FACTORIES.map((factory8) => factory8.name);
8092
+ const allExtendedDiagnosticNames = ALL_DIAGNOSTIC_FACTORIES.map((factory9) => factory9.name);
8038
8093
  for (const [checkName, category] of Object.entries((_c = (_b = options.extendedDiagnostics) == null ? void 0 : _b.checks) != null ? _c : {})) {
8039
8094
  if (!allExtendedDiagnosticNames.includes(checkName)) {
8040
8095
  yield makeConfigDiagnostic({
@@ -8713,4 +8768,4 @@ export {
8713
8768
  * Use of this source code is governed by an MIT-style license that can be
8714
8769
  * found in the LICENSE file at https://angular.io/license
8715
8770
  */
8716
- //# sourceMappingURL=chunk-VBLBTWOL.js.map
8771
+ //# sourceMappingURL=chunk-EKZWOVDR.js.map