@angular/compiler-cli 13.0.0-rc.2 → 13.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.
@@ -8323,7 +8323,7 @@ function getInheritedUndecoratedCtorDiagnostic(node, baseClass, reader) {
8323
8323
  }
8324
8324
 
8325
8325
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/src/directive.mjs
8326
- import { compileClassMetadata, compileDeclareClassMetadata, compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, emitDistinctChangesOnlyDefaultValue, ExternalExpr as ExternalExpr5, FactoryTarget, getSafePropertyAccessString, makeBindingParser, parseHostBindings, verifyHostBindings, WrappedNodeExpr as WrappedNodeExpr4 } from "@angular/compiler";
8326
+ import { compileClassMetadata, compileDeclareClassMetadata, compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, createMayBeForwardRefExpression, emitDistinctChangesOnlyDefaultValue, ExternalExpr as ExternalExpr5, FactoryTarget, getSafePropertyAccessString, makeBindingParser, parseHostBindings, verifyHostBindings, WrappedNodeExpr as WrappedNodeExpr4 } from "@angular/compiler";
8327
8327
  import ts37 from "typescript";
8328
8328
 
8329
8329
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/src/factory.mjs
@@ -8733,17 +8733,17 @@ function extractDirectiveMetadata(clazz, decorator, reflector, evaluator, isCore
8733
8733
  };
8734
8734
  }
8735
8735
  function extractQueryMetadata(exprNode, name, args, propertyName, reflector, evaluator) {
8736
- var _a;
8737
8736
  if (args.length === 0) {
8738
8737
  throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, exprNode, `@${name} must have arguments`);
8739
8738
  }
8740
8739
  const first = name === "ViewChild" || name === "ContentChild";
8741
- const node = (_a = tryUnwrapForwardRef(args[0], reflector)) != null ? _a : args[0];
8740
+ const forwardReferenceTarget = tryUnwrapForwardRef(args[0], reflector);
8741
+ const node = forwardReferenceTarget != null ? forwardReferenceTarget : args[0];
8742
8742
  const arg = evaluator.evaluate(node);
8743
8743
  let isStatic2 = false;
8744
8744
  let predicate = null;
8745
8745
  if (arg instanceof Reference || arg instanceof DynamicValue) {
8746
- predicate = new WrappedNodeExpr4(node);
8746
+ predicate = createMayBeForwardRefExpression(new WrappedNodeExpr4(node), forwardReferenceTarget !== null ? 2 : 0);
8747
8747
  } else if (typeof arg === "string") {
8748
8748
  predicate = [arg];
8749
8749
  } else if (isStringArrayOrDie(arg, `@${name} predicate`, node)) {
@@ -8988,7 +8988,7 @@ var QUERY_TYPES = new Set([
8988
8988
  ]);
8989
8989
 
8990
8990
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.mjs
8991
- import { compileClassMetadata as compileClassMetadata2, compileDeclareClassMetadata as compileDeclareClassMetadata2, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule, CUSTOM_ELEMENTS_SCHEMA, ExternalExpr as ExternalExpr6, FactoryTarget as FactoryTarget2, InvokeFunctionExpr, LiteralArrayExpr as LiteralArrayExpr2, LiteralExpr as LiteralExpr3, NO_ERRORS_SCHEMA, R3Identifiers, STRING_TYPE, WrappedNodeExpr as WrappedNodeExpr5 } from "@angular/compiler";
8991
+ import { compileClassMetadata as compileClassMetadata2, compileDeclareClassMetadata as compileDeclareClassMetadata2, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule, CUSTOM_ELEMENTS_SCHEMA, ExternalExpr as ExternalExpr6, FactoryTarget as FactoryTarget2, InvokeFunctionExpr, LiteralArrayExpr as LiteralArrayExpr2, NO_ERRORS_SCHEMA, R3Identifiers, WrappedNodeExpr as WrappedNodeExpr5 } from "@angular/compiler";
8992
8992
  import ts38 from "typescript";
8993
8993
  var NgModuleSymbol = class extends SemanticSymbol {
8994
8994
  constructor() {
@@ -9035,7 +9035,7 @@ var NgModuleSymbol = class extends SemanticSymbol {
9035
9035
  }
9036
9036
  };
9037
9037
  var NgModuleDecoratorHandler = class {
9038
- constructor(reflector, evaluator, metaReader, metaRegistry, scopeRegistry, referencesRegistry, isCore, refEmitter, factoryTracker, annotateForClosureCompiler, injectableRegistry, perf, localeId) {
9038
+ constructor(reflector, evaluator, metaReader, metaRegistry, scopeRegistry, referencesRegistry, isCore, refEmitter, factoryTracker, annotateForClosureCompiler, injectableRegistry, perf) {
9039
9039
  this.reflector = reflector;
9040
9040
  this.evaluator = evaluator;
9041
9041
  this.metaReader = metaReader;
@@ -9048,7 +9048,6 @@ var NgModuleDecoratorHandler = class {
9048
9048
  this.annotateForClosureCompiler = annotateForClosureCompiler;
9049
9049
  this.injectableRegistry = injectableRegistry;
9050
9050
  this.perf = perf;
9051
- this.localeId = localeId;
9052
9051
  this.precedence = HandlerPrecedence.PRIMARY;
9053
9052
  this.name = NgModuleDecoratorHandler.name;
9054
9053
  }
@@ -9334,14 +9333,6 @@ var NgModuleDecoratorHandler = class {
9334
9333
  type: injectorDef.type
9335
9334
  }
9336
9335
  ];
9337
- if (this.localeId) {
9338
- res.push({
9339
- name: "\u0275loc",
9340
- initializer: new LiteralExpr3(this.localeId),
9341
- statements: [],
9342
- type: STRING_TYPE
9343
- });
9344
- }
9345
9336
  return res;
9346
9337
  }
9347
9338
  _toR3Reference(valueRef, valueContext, typeContext) {
@@ -10315,7 +10306,7 @@ function checkCustomElementSelectorForErrors(selector) {
10315
10306
  }
10316
10307
 
10317
10308
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/src/injectable.mjs
10318
- import { compileClassMetadata as compileClassMetadata4, compileDeclareClassMetadata as compileDeclareClassMetadata4, compileDeclareInjectableFromMetadata, compileInjectable, createR3ProviderExpression, FactoryTarget as FactoryTarget4, LiteralExpr as LiteralExpr4, WrappedNodeExpr as WrappedNodeExpr7 } from "@angular/compiler";
10309
+ import { compileClassMetadata as compileClassMetadata4, compileDeclareClassMetadata as compileDeclareClassMetadata4, compileDeclareInjectableFromMetadata, compileInjectable, createMayBeForwardRefExpression as createMayBeForwardRefExpression2, FactoryTarget as FactoryTarget4, LiteralExpr as LiteralExpr3, WrappedNodeExpr as WrappedNodeExpr7 } from "@angular/compiler";
10319
10310
  import ts40 from "typescript";
10320
10311
  var InjectableDecoratorHandler = class {
10321
10312
  constructor(reflector, isCore, strictCtorDeps, injectableRegistry, perf, errorOnDuplicateProv = true) {
@@ -10403,7 +10394,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
10403
10394
  type,
10404
10395
  typeArgumentCount,
10405
10396
  internalType,
10406
- providedIn: createR3ProviderExpression(new LiteralExpr4(null), false)
10397
+ providedIn: createMayBeForwardRefExpression2(new LiteralExpr3(null), 0)
10407
10398
  };
10408
10399
  } else if (decorator.args.length === 1) {
10409
10400
  const metaNode = decorator.args[0];
@@ -10411,7 +10402,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
10411
10402
  throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, metaNode, `@Injectable argument must be an object literal`);
10412
10403
  }
10413
10404
  const meta = reflectObjectLiteral(metaNode);
10414
- const providedIn = meta.has("providedIn") ? getProviderExpression(meta.get("providedIn"), reflector) : createR3ProviderExpression(new LiteralExpr4(null), false);
10405
+ const providedIn = meta.has("providedIn") ? getProviderExpression(meta.get("providedIn"), reflector) : createMayBeForwardRefExpression2(new LiteralExpr3(null), 0);
10415
10406
  let deps = void 0;
10416
10407
  if ((meta.has("useClass") || meta.has("useFactory")) && meta.has("deps")) {
10417
10408
  const depsExpr = meta.get("deps");
@@ -10439,7 +10430,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
10439
10430
  }
10440
10431
  function getProviderExpression(expression, reflector) {
10441
10432
  const forwardRefValue = tryUnwrapForwardRef(expression, reflector);
10442
- return createR3ProviderExpression(new WrappedNodeExpr7(forwardRefValue != null ? forwardRefValue : expression), forwardRefValue !== null);
10433
+ return createMayBeForwardRefExpression2(new WrappedNodeExpr7(forwardRefValue != null ? forwardRefValue : expression), forwardRefValue !== null ? 2 : 0);
10443
10434
  }
10444
10435
  function extractInjectableCtorDeps(clazz, meta, decorator, reflector, isCore, strictCtorDeps) {
10445
10436
  if (decorator.args === null) {
@@ -14500,12 +14491,7 @@ var TcbDirectiveInputsOp = class extends TcbOp {
14500
14491
  let dirId = null;
14501
14492
  const inputs = getBoundInputs(this.dir, this.node, this.tcb);
14502
14493
  for (const input of inputs) {
14503
- let expr = translateInput(input.attribute, this.tcb, this.scope);
14504
- if (!this.tcb.env.config.checkTypeOfInputBindings) {
14505
- expr = tsCastToAny(expr);
14506
- } else if (!this.tcb.env.config.strictNullInputBindings) {
14507
- expr = ts67.createNonNullExpression(expr);
14508
- }
14494
+ const expr = widenBinding(translateInput(input.attribute, this.tcb, this.scope), this.tcb);
14509
14495
  let assignment = wrapForDiagnostics(expr);
14510
14496
  for (const fieldName of input.fieldNames) {
14511
14497
  let target;
@@ -14626,12 +14612,7 @@ var TcbUnclaimedInputsOp = class extends TcbOp {
14626
14612
  if (binding.type === 0 && this.claimedInputs.has(binding.name)) {
14627
14613
  continue;
14628
14614
  }
14629
- let expr = tcbExpression(binding.value, this.tcb, this.scope);
14630
- if (!this.tcb.env.config.checkTypeOfInputBindings) {
14631
- expr = tsCastToAny(expr);
14632
- } else if (!this.tcb.env.config.strictNullInputBindings) {
14633
- expr = ts67.createNonNullExpression(expr);
14634
- }
14615
+ const expr = widenBinding(tcbExpression(binding.value, this.tcb, this.scope), this.tcb);
14635
14616
  if (this.tcb.env.config.checkTypeOfDomBindings && binding.type === 0) {
14636
14617
  if (binding.name !== "style" && binding.name !== "class") {
14637
14618
  if (elId === null) {
@@ -15116,12 +15097,7 @@ function tcbCallTypeCtor(dir, tcb, inputs) {
15116
15097
  const members = inputs.map((input) => {
15117
15098
  const propertyName = ts67.createStringLiteral(input.field);
15118
15099
  if (input.type === "binding") {
15119
- let expr = input.expression;
15120
- if (!tcb.env.config.checkTypeOfInputBindings) {
15121
- expr = tsCastToAny(expr);
15122
- } else if (!tcb.env.config.strictNullInputBindings) {
15123
- expr = ts67.createNonNullExpression(expr);
15124
- }
15100
+ const expr = widenBinding(input.expression, tcb);
15125
15101
  const assignment = ts67.createPropertyAssignment(propertyName, wrapForDiagnostics(expr));
15126
15102
  addParseSpanInfo(assignment, input.sourceSpan);
15127
15103
  return assignment;
@@ -15158,6 +15134,19 @@ function translateInput(attr, tcb, scope) {
15158
15134
  return ts67.createStringLiteral(attr.value);
15159
15135
  }
15160
15136
  }
15137
+ function widenBinding(expr, tcb) {
15138
+ if (!tcb.env.config.checkTypeOfInputBindings) {
15139
+ return tsCastToAny(expr);
15140
+ } else if (!tcb.env.config.strictNullInputBindings) {
15141
+ if (ts67.isObjectLiteralExpression(expr) || ts67.isArrayLiteralExpression(expr)) {
15142
+ return expr;
15143
+ } else {
15144
+ return ts67.createNonNullExpression(expr);
15145
+ }
15146
+ } else {
15147
+ return expr;
15148
+ }
15149
+ }
15161
15150
  var EVENT_PARAMETER = "$event";
15162
15151
  function tcbCreateEventHandler(event, tcb, scope, eventType) {
15163
15152
  const handler = tcbEventHandlerExpression(event.handler, tcb, scope);
@@ -17159,7 +17148,7 @@ var NgCompiler = class {
17159
17148
  new DirectiveDecoratorHandler(reflector, evaluator, metaRegistry, scopeRegistry, metaReader, injectableRegistry, isCore, semanticDepGraphUpdater, this.closureCompilerEnabled, false, this.delegatingPerfRecorder),
17160
17149
  new PipeDecoratorHandler(reflector, evaluator, metaRegistry, scopeRegistry, injectableRegistry, isCore, this.delegatingPerfRecorder),
17161
17150
  new InjectableDecoratorHandler(reflector, isCore, this.options.strictInjectionParameters || false, injectableRegistry, this.delegatingPerfRecorder),
17162
- new NgModuleDecoratorHandler(reflector, evaluator, metaReader, metaRegistry, scopeRegistry, referencesRegistry, isCore, refEmitter, this.adapter.factoryTracker, this.closureCompilerEnabled, injectableRegistry, this.delegatingPerfRecorder, this.options.i18nInLocale)
17151
+ new NgModuleDecoratorHandler(reflector, evaluator, metaReader, metaRegistry, scopeRegistry, referencesRegistry, isCore, refEmitter, this.adapter.factoryTracker, this.closureCompilerEnabled, injectableRegistry, this.delegatingPerfRecorder)
17163
17152
  ];
17164
17153
  const traitCompiler = new TraitCompiler(handlers, reflector, this.delegatingPerfRecorder, this.incrementalCompilation, this.options.compileNonExportedClasses !== false, compilationMode, dtsTransforms, semanticDepGraphUpdater);
17165
17154
  const notifyingDriver = new NotifyingProgramDriverWrapper(this.programDriver, (program) => {
@@ -17348,7 +17337,14 @@ import ts74 from "typescript";
17348
17337
 
17349
17338
  // bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/diagnostics/typescript_version.mjs
17350
17339
  function toNumbers(value) {
17351
- return value.split(".").map(Number);
17340
+ const suffixIndex = value.lastIndexOf("-");
17341
+ return value.slice(0, suffixIndex === -1 ? value.length : suffixIndex).split(".").map((segment) => {
17342
+ const parsed = parseInt(segment, 10);
17343
+ if (isNaN(parsed)) {
17344
+ throw Error(`Unable to parse version string ${value}.`);
17345
+ }
17346
+ return parsed;
17347
+ });
17352
17348
  }
17353
17349
  function compareNumbers(a, b) {
17354
17350
  const max = Math.max(a.length, b.length);