@angular/core 19.0.0 → 19.0.1

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.
Files changed (32) hide show
  1. package/fesm2022/core.mjs +6955 -6854
  2. package/fesm2022/core.mjs.map +1 -1
  3. package/fesm2022/primitives/event-dispatch.mjs +1 -1
  4. package/fesm2022/primitives/signals.mjs +1 -1
  5. package/fesm2022/rxjs-interop.mjs +1 -1
  6. package/fesm2022/testing.mjs +4 -4
  7. package/index.d.ts +56 -5
  8. package/package.json +1 -1
  9. package/primitives/event-dispatch/index.d.ts +1 -1
  10. package/primitives/signals/index.d.ts +1 -1
  11. package/rxjs-interop/index.d.ts +1 -1
  12. package/schematics/bundles/{checker-e3da3b0a.js → checker-3cbc9cc1.js} +24 -7
  13. package/schematics/bundles/{combine_units-2adebceb.js → combine_units-c36a3065.js} +5 -3
  14. package/schematics/bundles/{compiler_host-d642e87e.js → compiler_host-087c5caa.js} +2 -2
  15. package/schematics/bundles/control-flow-migration.js +3 -3
  16. package/schematics/bundles/explicit-standalone-flag.js +3 -3
  17. package/schematics/bundles/imports-4ac08251.js +1 -1
  18. package/schematics/bundles/inject-migration.js +80 -15
  19. package/schematics/bundles/leading_space-d190b83b.js +1 -1
  20. package/schematics/bundles/{migrate_ts_type_references-ed2c0669.js → migrate_ts_type_references-bb0c286a.js} +4 -4
  21. package/schematics/bundles/nodes-0e7d45ca.js +1 -1
  22. package/schematics/bundles/output-migration.js +4 -4
  23. package/schematics/bundles/pending-tasks.js +3 -3
  24. package/schematics/bundles/{program-f984ab63.js → program-561595c4.js} +33 -15
  25. package/schematics/bundles/project_tsconfig_paths-e9ccccbf.js +1 -1
  26. package/schematics/bundles/provide-initializer.js +36 -29
  27. package/schematics/bundles/route-lazy-loading.js +27 -23
  28. package/schematics/bundles/signal-input-migration.js +5 -5
  29. package/schematics/bundles/signal-queries-migration.js +5 -5
  30. package/schematics/bundles/signals.js +5 -5
  31. package/schematics/bundles/standalone-migration.js +5 -5
  32. package/testing/index.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v19.0.0
2
+ * @license Angular v19.0.1
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v19.0.0
2
+ * @license Angular v19.0.1
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v19.0.0
2
+ * @license Angular v19.0.1
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v19.0.0
2
+ * @license Angular v19.0.1
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -175,10 +175,10 @@ class TestBedApplicationErrorHandler {
175
175
  throw e;
176
176
  }
177
177
  }
178
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: TestBedApplicationErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
179
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: TestBedApplicationErrorHandler });
178
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: TestBedApplicationErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
179
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: TestBedApplicationErrorHandler });
180
180
  }
181
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: TestBedApplicationErrorHandler, decorators: [{
181
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: TestBedApplicationErrorHandler, decorators: [{
182
182
  type: Injectable
183
183
  }] });
184
184
 
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v19.0.0
2
+ * @license Angular v19.0.1
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -479,6 +479,7 @@ declare class AfterRenderImpl {
479
479
  private readonly deferredRegistrations;
480
480
  /** Whether the `AfterRenderManager` is currently executing hooks. */
481
481
  executing: boolean;
482
+ constructor();
482
483
  /**
483
484
  * Run the sequence of phases of hooks, once through. As a result of executing some hooks, more
484
485
  * might be scheduled.
@@ -486,6 +487,7 @@ declare class AfterRenderImpl {
486
487
  execute(): void;
487
488
  register(sequence: AfterRenderSequence): void;
488
489
  unregister(sequence: AfterRenderSequence): void;
490
+ protected maybeTrace<T>(fn: () => T, snapshot: ɵTracingSnapshot | null): T;
489
491
  /** @nocollapse */
490
492
  static ɵprov: unknown;
491
493
  }
@@ -604,6 +606,7 @@ declare class AfterRenderSequence implements AfterRenderRef {
604
606
  readonly impl: AfterRenderImpl;
605
607
  readonly hooks: AfterRenderHooks;
606
608
  once: boolean;
609
+ snapshot: ɵTracingSnapshot | null;
607
610
  /**
608
611
  * Whether this sequence errored or was destroyed during this execution, and hooks should no
609
612
  * longer run for it.
@@ -615,7 +618,7 @@ declare class AfterRenderSequence implements AfterRenderRef {
615
618
  */
616
619
  pipelinedValue: unknown;
617
620
  private unregisterOnDestroy;
618
- constructor(impl: AfterRenderImpl, hooks: AfterRenderHooks, once: boolean, destroyRef: DestroyRef | null);
621
+ constructor(impl: AfterRenderImpl, hooks: AfterRenderHooks, once: boolean, destroyRef: DestroyRef | null, snapshot?: ɵTracingSnapshot | null);
619
622
  afterRun(): void;
620
623
  destroy(): void;
621
624
  }
@@ -1014,6 +1017,7 @@ export declare class ApplicationRef {
1014
1017
  * Returns an Observable that indicates when the application is stable or unstable.
1015
1018
  */
1016
1019
  readonly isStable: Observable<boolean>;
1020
+ constructor();
1017
1021
  /**
1018
1022
  * @returns A promise that resolves when the application becomes stable
1019
1023
  */
@@ -2593,7 +2597,10 @@ declare const CONTEXT = 8;
2593
2597
  * * `elementInjector` (optional): An `ElementInjector` instance, see additional info about it
2594
2598
  * [here](guide/di/hierarchical-dependency-injection#elementinjector).
2595
2599
  * * `projectableNodes` (optional): A list of DOM nodes that should be projected through
2596
- * [`<ng-content>`](api/core/ng-content) of the new component instance.
2600
+ * [`<ng-content>`](api/core/ng-content) of the new component instance, e.g.,
2601
+ * `[[element1, element2]]`: projects `element1` and `element2` into the same `<ng-content>`.
2602
+ * `[[element1, element2], [element3]]`: projects `element1` and `element2` into one `<ng-content>`,
2603
+ * and `element3` into a separate `<ng-content>`.
2597
2604
  * @returns ComponentRef instance that represents a given Component.
2598
2605
  *
2599
2606
  * @publicApi
@@ -4249,6 +4256,12 @@ export declare type EnvironmentProviders = {
4249
4256
  * }
4250
4257
  * }
4251
4258
  *
4259
+ * // Provide in standalone apps
4260
+ * bootstrapApplication(AppComponent, {
4261
+ * providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
4262
+ * })
4263
+ *
4264
+ * // Provide in module-based apps
4252
4265
  * @NgModule({
4253
4266
  * providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
4254
4267
  * })
@@ -7026,8 +7039,8 @@ declare interface LView<T = unknown> extends Array<any> {
7026
7039
  * - For inline views, the context is null.
7027
7040
  */
7028
7041
  [CONTEXT]: T;
7029
- /** An optional Module Injector to be used as fall back after Element Injectors are consulted. */
7030
- readonly [INJECTOR_2]: Injector | null;
7042
+ /** A Module Injector to be used as fall back after Element Injectors are consulted. */
7043
+ readonly [INJECTOR_2]: Injector;
7031
7044
  /**
7032
7045
  * Contextual data that is shared across multiple instances of `LView` in the same application.
7033
7046
  */
@@ -12909,6 +12922,7 @@ export declare class ɵChangeDetectionSchedulerImpl implements ɵChangeDetection
12909
12922
  private readonly taskService;
12910
12923
  private readonly ngZone;
12911
12924
  private readonly zonelessEnabled;
12925
+ private readonly tracing;
12912
12926
  private readonly disableScheduling;
12913
12927
  private readonly zoneIsDefined;
12914
12928
  private readonly schedulerTickApplyArgs;
@@ -14681,6 +14695,39 @@ export declare const ɵTESTABILITY: InjectionToken<Testability>;
14681
14695
  */
14682
14696
  export declare const ɵTESTABILITY_GETTER: InjectionToken<GetTestability>;
14683
14697
 
14698
+ /** Actions that are supported by the tracing framework. */
14699
+ export declare enum ɵTracingAction {
14700
+ CHANGE_DETECTION = 0,
14701
+ AFTER_NEXT_RENDER = 1
14702
+ }
14703
+
14704
+ /**
14705
+ * Injection token for a `TracingService`, optionally provided.
14706
+ */
14707
+ export declare const ɵTracingService: InjectionToken<ɵTracingService<ɵTracingSnapshot>>;
14708
+
14709
+ /**
14710
+ * Tracing mechanism which can associate causes (snapshots) with runs of
14711
+ * subsequent operations.
14712
+ *
14713
+ * Not defined by Angular directly, but defined in contexts where tracing is
14714
+ * desired.
14715
+ */
14716
+ export declare interface ɵTracingService<T extends ɵTracingSnapshot> {
14717
+ /**
14718
+ * Take a snapshot of the current context which will be stored by Angular and
14719
+ * used when additional work is performed that was scheduled in this context.
14720
+ *
14721
+ * @param linkedSnapshot Optional snapshot to use link to the current context.
14722
+ */
14723
+ snapshot(linkedSnapshot: T | null): T;
14724
+ }
14725
+
14726
+ /** A single tracing snapshot. */
14727
+ export declare interface ɵTracingSnapshot {
14728
+ run<T>(action: ɵTracingAction, fn: () => T): T;
14729
+ }
14730
+
14684
14731
  /**
14685
14732
  * Compute the pair of transitive scopes (compilation scope and exported scope) for a given type
14686
14733
  * (either a NgModule or a standalone component / directive / pipe).
@@ -14968,6 +15015,10 @@ export declare class ɵViewRef<T> implements EmbeddedViewRef<T>, ChangeDetectorR
14968
15015
  /**
14969
15016
  * Returns a Promise that resolves when the application becomes stable after this method is called
14970
15017
  * the first time.
15018
+ *
15019
+ * Note: this function is unused in the FW code, but it's still present since the CLI code relies
15020
+ * on it currently (see https://github.com/angular/angular-cli/blob/20411f696eb52c500e096e3dfc5e195185794edc/packages/angular/ssr/src/routes/ng-routes.ts#L435).
15021
+ * Remove this function once CLI code is updated to use `ApplicationRef.whenStable` instead.
14971
15022
  */
14972
15023
  export declare function ɵwhenStable(applicationRef: ApplicationRef): Promise<void>;
14973
15024
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/core",
3
- "version": "19.0.0",
3
+ "version": "19.0.1",
4
4
  "description": "Angular - the core framework",
5
5
  "author": "angular",
6
6
  "license": "MIT",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v19.0.0
2
+ * @license Angular v19.0.1
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v19.0.0
2
+ * @license Angular v19.0.1
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v19.0.0
2
+ * @license Angular v19.0.1
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0
3
+ * @license Angular v19.0.1
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -6466,10 +6466,23 @@ class ParseError {
6466
6466
  span;
6467
6467
  msg;
6468
6468
  level;
6469
- constructor(span, msg, level = ParseErrorLevel.ERROR) {
6469
+ relatedError;
6470
+ constructor(
6471
+ /** Location of the error. */
6472
+ span,
6473
+ /** Error message. */
6474
+ msg,
6475
+ /** Severity level of the error. */
6476
+ level = ParseErrorLevel.ERROR,
6477
+ /**
6478
+ * Error that caused the error to be surfaced. For example, an error in a sub-expression that
6479
+ * couldn't be parsed. Not guaranteed to be defined, but can be used to provide more context.
6480
+ */
6481
+ relatedError) {
6470
6482
  this.span = span;
6471
6483
  this.msg = msg;
6472
6484
  this.level = level;
6485
+ this.relatedError = relatedError;
6473
6486
  }
6474
6487
  contextualMessage() {
6475
6488
  const ctx = this.span.start.getContext(100, 3);
@@ -26503,12 +26516,12 @@ class BindingParser {
26503
26516
  return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo, absoluteOffset);
26504
26517
  }
26505
26518
  }
26506
- _reportError(message, sourceSpan, level = ParseErrorLevel.ERROR) {
26507
- this.errors.push(new ParseError(sourceSpan, message, level));
26519
+ _reportError(message, sourceSpan, level = ParseErrorLevel.ERROR, relatedError) {
26520
+ this.errors.push(new ParseError(sourceSpan, message, level, relatedError));
26508
26521
  }
26509
26522
  _reportExpressionParserErrors(errors, sourceSpan) {
26510
26523
  for (const error of errors) {
26511
- this._reportError(error.message, sourceSpan);
26524
+ this._reportError(error.message, sourceSpan, undefined, error);
26512
26525
  }
26513
26526
  }
26514
26527
  /**
@@ -30310,7 +30323,7 @@ function publishFacade(global) {
30310
30323
  * @description
30311
30324
  * Entry point for all public APIs of the compiler package.
30312
30325
  */
30313
- new Version('19.0.0');
30326
+ new Version('19.0.1');
30314
30327
 
30315
30328
  const _I18N_ATTR = 'i18n';
30316
30329
  const _I18N_ATTR_PREFIX = 'i18n-';
@@ -31718,7 +31731,7 @@ class NodeJSPathManipulation {
31718
31731
  // G3-ESM-MARKER: G3 uses CommonJS, but externally everything in ESM.
31719
31732
  // CommonJS/ESM interop for determining the current file name and containing dir.
31720
31733
  const isCommonJS = typeof __filename !== 'undefined';
31721
- const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || new URL('checker-e3da3b0a.js', document.baseURI).href));
31734
+ const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || new URL('checker-3cbc9cc1.js', document.baseURI).href));
31722
31735
  const currentFileName = isCommonJS ? __filename : url.fileURLToPath(currentFileUrl);
31723
31736
  /**
31724
31737
  * A wrapper around the Node.js file-system that supports readonly operations and path manipulation.
@@ -38505,6 +38518,9 @@ class SourceMap {
38505
38518
  if (typeof properties.x_google_ignoreList !== 'undefined') {
38506
38519
  this.x_google_ignoreList = properties.x_google_ignoreList;
38507
38520
  }
38521
+ if (typeof properties.debugId !== 'undefined') {
38522
+ this.debugId = properties.debugId;
38523
+ }
38508
38524
  }
38509
38525
 
38510
38526
  toString() {
@@ -45840,6 +45856,7 @@ exports.ParseLocation = ParseLocation;
45840
45856
  exports.ParseSourceFile = ParseSourceFile;
45841
45857
  exports.ParseSourceSpan = ParseSourceSpan;
45842
45858
  exports.Parser = Parser$1;
45859
+ exports.ParserError = ParserError;
45843
45860
  exports.Placeholder = Placeholder;
45844
45861
  exports.PropertyRead = PropertyRead;
45845
45862
  exports.PropertyWrite = PropertyWrite;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0
3
+ * @license Angular v19.0.1
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -10,8 +10,8 @@ var core = require('@angular-devkit/core');
10
10
  var posixPath = require('node:path/posix');
11
11
  var os = require('os');
12
12
  var ts = require('typescript');
13
- var checker = require('./checker-e3da3b0a.js');
14
- var program = require('./program-f984ab63.js');
13
+ var checker = require('./checker-3cbc9cc1.js');
14
+ var program = require('./program-561595c4.js');
15
15
  require('path');
16
16
 
17
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -435,6 +435,8 @@ const defaultMigrationTsOptions = {
435
435
  skipLibCheck: true,
436
436
  skipDefaultLibCheck: true,
437
437
  noEmit: true,
438
+ // Does not apply to g3 and externally is enforced when the app is built by the compiler.
439
+ disableTypeScriptVersionCheck: true,
438
440
  };
439
441
  /**
440
442
  * Creates an instance of a TypeScript program for the given project.
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0
3
+ * @license Angular v19.0.1
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
7
7
  'use strict';
8
8
 
9
9
  var ts = require('typescript');
10
- var checker = require('./checker-e3da3b0a.js');
10
+ var checker = require('./checker-3cbc9cc1.js');
11
11
  require('os');
12
12
  var p = require('path');
13
13
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0
3
+ * @license Angular v19.0.1
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -10,8 +10,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
10
10
 
11
11
  var schematics = require('@angular-devkit/schematics');
12
12
  var p = require('path');
13
- var compiler_host = require('./compiler_host-d642e87e.js');
14
- var checker = require('./checker-e3da3b0a.js');
13
+ var compiler_host = require('./compiler_host-087c5caa.js');
14
+ var checker = require('./checker-3cbc9cc1.js');
15
15
  var ts = require('typescript');
16
16
  require('os');
17
17
  require('fs');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0
3
+ * @license Angular v19.0.1
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -11,11 +11,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
11
11
  var schematics = require('@angular-devkit/schematics');
12
12
  var p = require('path');
13
13
  var project_tsconfig_paths = require('./project_tsconfig_paths-e9ccccbf.js');
14
- var compiler_host = require('./compiler_host-d642e87e.js');
14
+ var compiler_host = require('./compiler_host-087c5caa.js');
15
15
  var ts = require('typescript');
16
16
  var imports = require('./imports-4ac08251.js');
17
17
  require('@angular-devkit/core');
18
- require('./checker-e3da3b0a.js');
18
+ require('./checker-3cbc9cc1.js');
19
19
  require('os');
20
20
  require('fs');
21
21
  require('module');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0
3
+ * @license Angular v19.0.1
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0
3
+ * @license Angular v19.0.1
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -10,12 +10,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
10
10
 
11
11
  var schematics = require('@angular-devkit/schematics');
12
12
  var p = require('path');
13
- var compiler_host = require('./compiler_host-d642e87e.js');
13
+ var compiler_host = require('./compiler_host-087c5caa.js');
14
14
  var ts = require('typescript');
15
15
  var nodes = require('./nodes-0e7d45ca.js');
16
16
  var imports = require('./imports-4ac08251.js');
17
17
  var leading_space = require('./leading_space-d190b83b.js');
18
- require('./checker-e3da3b0a.js');
18
+ require('./checker-3cbc9cc1.js');
19
19
  require('os');
20
20
  require('fs');
21
21
  require('module');
@@ -146,13 +146,13 @@ function getConstructorUnusedParameters(declaration, localTypeChecker, removedSt
146
146
  if (!declaration.body) {
147
147
  return topLevelParameters;
148
148
  }
149
- declaration.body.forEachChild(function walk(node) {
149
+ const analyze = (node) => {
150
150
  // Don't descend into statements that were removed already.
151
151
  if (ts__default["default"].isStatement(node) && removedStatements.has(node)) {
152
152
  return;
153
153
  }
154
154
  if (!ts__default["default"].isIdentifier(node) || !topLevelParameterNames.has(node.text)) {
155
- node.forEachChild(walk);
155
+ node.forEachChild(analyze);
156
156
  return;
157
157
  }
158
158
  // Don't consider `this.<name>` accesses as being references to
@@ -171,7 +171,13 @@ function getConstructorUnusedParameters(declaration, localTypeChecker, removedSt
171
171
  }
172
172
  }
173
173
  });
174
+ };
175
+ declaration.parameters.forEach((param) => {
176
+ if (param.initializer) {
177
+ analyze(param.initializer);
178
+ }
174
179
  });
180
+ declaration.body.forEachChild(analyze);
175
181
  for (const param of topLevelParameters) {
176
182
  if (!accessedTopLevelParameters.has(param)) {
177
183
  unusedParams.add(param);
@@ -210,6 +216,41 @@ function getSuperParameters(declaration, superCall, localTypeChecker) {
210
216
  });
211
217
  return usedParams;
212
218
  }
219
+ /**
220
+ * Determines if a specific parameter has references to other parameters.
221
+ * @param param Parameter to check.
222
+ * @param allParameters All parameters of the containing function.
223
+ * @param localTypeChecker Type checker scoped to the current file.
224
+ */
225
+ function parameterReferencesOtherParameters(param, allParameters, localTypeChecker) {
226
+ // A parameter can only reference other parameters through its initializer.
227
+ if (!param.initializer || allParameters.length < 2) {
228
+ return false;
229
+ }
230
+ const paramNames = new Set();
231
+ for (const current of allParameters) {
232
+ if (current !== param && ts__default["default"].isIdentifier(current.name)) {
233
+ paramNames.add(current.name.text);
234
+ }
235
+ }
236
+ let result = false;
237
+ const analyze = (node) => {
238
+ if (ts__default["default"].isIdentifier(node) && paramNames.has(node.text) && !isAccessedViaThis(node)) {
239
+ const symbol = localTypeChecker.getSymbolAtLocation(node);
240
+ const referencesOtherParam = symbol?.declarations?.some((decl) => {
241
+ return allParameters.includes(decl);
242
+ });
243
+ if (referencesOtherParam) {
244
+ result = true;
245
+ }
246
+ }
247
+ if (!result) {
248
+ node.forEachChild(analyze);
249
+ }
250
+ };
251
+ analyze(param.initializer);
252
+ return result;
253
+ }
213
254
  /** Checks whether a parameter node declares a property on its class. */
214
255
  function parameterDeclaresProperty(node) {
215
256
  return !!node.modifiers?.some(({ kind }) => kind === ts__default["default"].SyntaxKind.PublicKeyword ||
@@ -587,7 +628,8 @@ function migrateClass(node, constructor, superCall, options, memberIndentation,
587
628
  for (const param of constructor.parameters) {
588
629
  const usedInSuper = superParameters !== null && superParameters.has(param);
589
630
  const usedInConstructor = !unusedParameters.has(param);
590
- migrateParameter(param, options, localTypeChecker, printer, tracker, superCall, usedInSuper, usedInConstructor, memberIndentation, innerIndentation, prependToConstructor, prependToClass, afterSuper);
631
+ const usesOtherParams = parameterReferencesOtherParameters(param, constructor.parameters, localTypeChecker);
632
+ migrateParameter(param, options, localTypeChecker, printer, tracker, superCall, usedInSuper, usedInConstructor, usesOtherParams, memberIndentation, innerIndentation, prependToConstructor, prependToClass, afterSuper);
591
633
  }
592
634
  // Delete all of the constructor overloads since below we're either going to
593
635
  // remove the implementation, or we're going to delete all of the parameters.
@@ -597,7 +639,7 @@ function migrateClass(node, constructor, superCall, options, memberIndentation,
597
639
  tracker.removeNode(member, true);
598
640
  }
599
641
  }
600
- if (canRemoveConstructor(options, constructor, removedStatementCount, superCall)) {
642
+ if (canRemoveConstructor(options, constructor, removedStatementCount, prependToConstructor, superCall)) {
601
643
  // Drop the constructor if it was empty.
602
644
  removedMembers.add(constructor);
603
645
  tracker.removeNode(constructor, true);
@@ -607,7 +649,15 @@ function migrateClass(node, constructor, superCall, options, memberIndentation,
607
649
  // We always do this no matter what is passed into `backwardsCompatibleConstructors`.
608
650
  stripConstructorParameters(constructor, tracker);
609
651
  if (prependToConstructor.length > 0) {
610
- tracker.insertText(sourceFile, (firstConstructorStatement || innerReference).getFullStart(), `\n${prependToConstructor.join('\n')}\n`);
652
+ if (firstConstructorStatement ||
653
+ (innerReference !== constructor &&
654
+ innerReference.getStart() >= constructor.getStart() &&
655
+ innerReference.getEnd() <= constructor.getEnd())) {
656
+ tracker.insertText(sourceFile, (firstConstructorStatement || innerReference).getFullStart(), `\n${prependToConstructor.join('\n')}\n`);
657
+ }
658
+ else {
659
+ tracker.insertText(sourceFile, constructor.body.getStart() + 1, `\n${prependToConstructor.map((p) => innerIndentation + p).join('\n')}\n${innerIndentation}`);
660
+ }
611
661
  }
612
662
  }
613
663
  if (afterSuper.length > 0 && superCall !== null) {
@@ -662,7 +712,7 @@ function migrateClass(node, constructor, superCall, options, memberIndentation,
662
712
  * @param propsToAdd Properties to be added to the class.
663
713
  * @param afterSuper Statements to be added after the `super` call.
664
714
  */
665
- function migrateParameter(node, options, localTypeChecker, printer, tracker, superCall, usedInSuper, usedInConstructor, memberIndentation, innerIndentation, prependToConstructor, propsToAdd, afterSuper) {
715
+ function migrateParameter(node, options, localTypeChecker, printer, tracker, superCall, usedInSuper, usedInConstructor, usesOtherParams, memberIndentation, innerIndentation, prependToConstructor, propsToAdd, afterSuper) {
666
716
  if (!ts__default["default"].isIdentifier(node.name)) {
667
717
  return;
668
718
  }
@@ -671,6 +721,9 @@ function migrateParameter(node, options, localTypeChecker, printer, tracker, sup
671
721
  const declaresProp = parameterDeclaresProperty(node);
672
722
  // If the parameter declares a property, we need to declare it (e.g. `private foo: Foo`).
673
723
  if (declaresProp) {
724
+ // We can't initialize the property if it's referenced within a `super` call or it references
725
+ // other parameters. See the logic further below for the initialization.
726
+ const canInitialize = !usedInSuper && !usesOtherParams;
674
727
  const prop = ts__default["default"].factory.createPropertyDeclaration(cloneModifiers(node.modifiers?.filter((modifier) => {
675
728
  // Strip out the DI decorators, as well as `public` which is redundant.
676
729
  return !ts__default["default"].isDecorator(modifier) && modifier.kind !== ts__default["default"].SyntaxKind.PublicKeyword;
@@ -678,10 +731,7 @@ function migrateParameter(node, options, localTypeChecker, printer, tracker, sup
678
731
  // Don't add the question token to private properties since it won't affect interface implementation.
679
732
  node.modifiers?.some((modifier) => modifier.kind === ts__default["default"].SyntaxKind.PrivateKeyword)
680
733
  ? undefined
681
- : node.questionToken,
682
- // We can't initialize the property if it's referenced within a `super` call.
683
- // See the logic further below for the initialization.
684
- usedInSuper ? node.type : undefined, usedInSuper ? undefined : ts__default["default"].factory.createIdentifier(PLACEHOLDER));
734
+ : node.questionToken, canInitialize ? undefined : node.type, canInitialize ? ts__default["default"].factory.createIdentifier(PLACEHOLDER) : undefined);
685
735
  propsToAdd.push(memberIndentation +
686
736
  replaceNodePlaceholder(node.getSourceFile(), prop, replacementCall, printer));
687
737
  }
@@ -714,6 +764,15 @@ function migrateParameter(node, options, localTypeChecker, printer, tracker, sup
714
764
  prependToConstructor.push(`${innerIndentation}const ${name} = ${replacementCall};`);
715
765
  }
716
766
  }
767
+ else if (usesOtherParams && declaresProp) {
768
+ const toAdd = `${innerIndentation}this.${name} = ${replacementCall};`;
769
+ if (superCall === null) {
770
+ prependToConstructor.push(toAdd);
771
+ }
772
+ else {
773
+ afterSuper.push(toAdd);
774
+ }
775
+ }
717
776
  }
718
777
  /**
719
778
  * Creates a replacement `inject` call from a function parameter.
@@ -800,6 +859,10 @@ function createInjectReplacementCall(param, options, localTypeChecker, printer,
800
859
  expression = ts__default["default"].factory.createNonNullExpression(expression);
801
860
  }
802
861
  }
862
+ // If the parameter is initialized, add the initializer as a fallback.
863
+ if (param.initializer) {
864
+ expression = ts__default["default"].factory.createBinaryExpression(expression, ts__default["default"].SyntaxKind.QuestionQuestionToken, param.initializer);
865
+ }
803
866
  return replaceNodePlaceholder(param.getSourceFile(), expression, injectedType, printer);
804
867
  }
805
868
  /**
@@ -956,10 +1019,11 @@ function cloneName(node) {
956
1019
  * @param options Options used to configure the migration.
957
1020
  * @param constructor Node representing the constructor.
958
1021
  * @param removedStatementCount Number of statements that were removed by the migration.
1022
+ * @param prependToConstructor Statements that should be prepended to the constructor.
959
1023
  * @param superCall Node representing the `super()` call within the constructor.
960
1024
  */
961
- function canRemoveConstructor(options, constructor, removedStatementCount, superCall) {
962
- if (options.backwardsCompatibleConstructors) {
1025
+ function canRemoveConstructor(options, constructor, removedStatementCount, prependToConstructor, superCall) {
1026
+ if (options.backwardsCompatibleConstructors || prependToConstructor.length > 0) {
963
1027
  return false;
964
1028
  }
965
1029
  const statementCount = constructor.body
@@ -1039,6 +1103,7 @@ function applyInternalOnlyChanges(node, constructor, localTypeChecker, tracker,
1039
1103
  result.toHoist.forEach((decl) => {
1040
1104
  prependToClass.push(memberIndentation + printer.printNode(ts__default["default"].EmitHint.Unspecified, decl, decl.getSourceFile()));
1041
1105
  tracker.removeNode(decl, true);
1106
+ removedMembers.add(decl);
1042
1107
  });
1043
1108
  // If we added any hoisted properties, separate them visually with a new line.
1044
1109
  if (prependToClass.length > 0) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0
3
+ * @license Angular v19.0.1
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0
3
+ * @license Angular v19.0.1
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
7
7
  'use strict';
8
8
 
9
- var checker = require('./checker-e3da3b0a.js');
9
+ var checker = require('./checker-3cbc9cc1.js');
10
10
  var ts = require('typescript');
11
11
  require('os');
12
12
  var assert = require('assert');
13
- var combine_units = require('./combine_units-2adebceb.js');
13
+ var combine_units = require('./combine_units-c36a3065.js');
14
14
  var leading_space = require('./leading_space-d190b83b.js');
15
- require('./program-f984ab63.js');
15
+ require('./program-561595c4.js');
16
16
  require('path');
17
17
 
18
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0
3
+ * @license Angular v19.0.1
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */