@angular/core 19.2.0 → 19.2.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.
Files changed (50) hide show
  1. package/fesm2022/core.mjs +317 -1646
  2. package/fesm2022/core.mjs.map +1 -1
  3. package/fesm2022/primitives/di.mjs +45 -0
  4. package/fesm2022/primitives/di.mjs.map +1 -0
  5. package/fesm2022/primitives/event-dispatch.mjs +3 -590
  6. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  7. package/fesm2022/primitives/signals.mjs +19 -9
  8. package/fesm2022/primitives/signals.mjs.map +1 -1
  9. package/fesm2022/rxjs-interop.mjs +8 -12
  10. package/fesm2022/rxjs-interop.mjs.map +1 -1
  11. package/fesm2022/testing.mjs +387 -241
  12. package/fesm2022/testing.mjs.map +1 -1
  13. package/fesm2022/weak_ref-DrMdAIDh.mjs +12 -0
  14. package/fesm2022/weak_ref-DrMdAIDh.mjs.map +1 -0
  15. package/index.d.ts +14138 -14924
  16. package/navigation_types.d-u4EOrrdZ.d.ts +121 -0
  17. package/package.json +5 -1
  18. package/primitives/di/index.d.ts +91 -0
  19. package/primitives/event-dispatch/index.d.ts +206 -310
  20. package/primitives/signals/index.d.ts +159 -196
  21. package/rxjs-interop/index.d.ts +73 -92
  22. package/schematics/bundles/{apply_import_manager-a4e62ded.js → apply_import_manager-C8MABThs.js} +13 -17
  23. package/schematics/bundles/{checker-2eecc677.js → checker-DP-zos5Q.js} +2961 -1060
  24. package/schematics/bundles/cleanup-unused-imports.js +22 -28
  25. package/schematics/bundles/{compiler_host-f313eac9.js → compiler_host-DzM2hemp.js} +20 -24
  26. package/schematics/bundles/control-flow-migration.js +82 -39
  27. package/schematics/bundles/explicit-standalone-flag.js +27 -33
  28. package/schematics/bundles/{imports-31a38653.js → imports-CIX-JgAN.js} +10 -15
  29. package/schematics/bundles/{index-afc3f749.js → index-CEdDCtp8.js} +56 -60
  30. package/schematics/bundles/{index-3891dd55.js → index-CrKEaRj_.js} +5 -5
  31. package/schematics/bundles/inject-migration.js +122 -128
  32. package/schematics/bundles/{leading_space-6e7a8ec6.js → leading_space-D9nQ8UQC.js} +2 -2
  33. package/schematics/bundles/{migrate_ts_type_references-1abf1f5f.js → migrate_ts_type_references-C0325A9V.js} +107 -112
  34. package/schematics/bundles/{ng_decorators-6878e227.js → ng_decorators-DznZ5jMl.js} +5 -9
  35. package/schematics/bundles/{nodes-ffdce442.js → nodes-B16H9JUd.js} +3 -7
  36. package/schematics/bundles/output-migration.js +40 -46
  37. package/schematics/bundles/pending-tasks.js +14 -20
  38. package/schematics/bundles/{program-24da9092.js → program-CRYsSwIq.js} +769 -2634
  39. package/schematics/bundles/{project_paths-64bc3947.js → project_paths-BoRVJPjW.js} +26 -24
  40. package/schematics/bundles/{project_tsconfig_paths-6c9cde78.js → project_tsconfig_paths-CDVxT6Ov.js} +2 -2
  41. package/schematics/bundles/{property_name-42030525.js → property_name-BBwFuqMe.js} +4 -8
  42. package/schematics/bundles/provide-initializer.js +14 -20
  43. package/schematics/bundles/route-lazy-loading.js +36 -42
  44. package/schematics/bundles/self-closing-tags-migration.js +55 -45
  45. package/schematics/bundles/signal-input-migration.js +61 -68
  46. package/schematics/bundles/signal-queries-migration.js +48 -55
  47. package/schematics/bundles/signals.js +10 -12
  48. package/schematics/bundles/standalone-migration.js +179 -185
  49. package/testing/index.d.ts +309 -471
  50. package/weak_ref.d-ttyj86RV.d.ts +9 -0
@@ -1,46 +1,60 @@
1
1
  /**
2
- * @license Angular v19.2.0
3
- * (c) 2010-2024 Google LLC. https://angular.io/
2
+ * @license Angular v19.2.2
3
+ * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
-
8
- import { ChangeDetectorRef } from '@angular/core';
9
- import { Component } from '@angular/core';
10
- import { ComponentRef } from '@angular/core';
11
- import { DebugElement } from '@angular/core';
12
- import { ɵDeferBlockBehavior as DeferBlockBehavior } from '@angular/core';
13
- import { ɵDeferBlockState as DeferBlockState } from '@angular/core';
14
- import { Directive } from '@angular/core';
15
- import { ElementRef } from '@angular/core';
16
- import { InjectFlags } from '@angular/core';
17
- import { InjectionToken } from '@angular/core';
18
- import { InjectOptions } from '@angular/core';
19
- import { NgModule } from '@angular/core';
20
- import { NgZone } from '@angular/core';
21
- import { Pipe } from '@angular/core';
22
- import { PlatformRef } from '@angular/core';
23
- import { ProviderToken } from '@angular/core';
24
- import { SchemaMetadata } from '@angular/core';
25
- import { Type } from '@angular/core';
26
- import { ɵDeferBlockDetails } from '@angular/core';
7
+ import { ɵDeferBlockDetails as _DeferBlockDetails, ɵDeferBlockState as _DeferBlockState, ComponentRef, DebugElement, ElementRef, ChangeDetectorRef, NgZone, SchemaMetadata, ɵDeferBlockBehavior as _DeferBlockBehavior, InjectionToken, PlatformRef, Type, ProviderToken, InjectOptions, InjectFlags, NgModule, Component, Directive, Pipe } from '@angular/core';
8
+ export { ɵDeferBlockBehavior as DeferBlockBehavior, ɵDeferBlockState as DeferBlockState } from '@angular/core';
9
+ import { a as Navigation, c as NavigationHistoryEntry, d as NavigationNavigateOptions, g as NavigationResult, e as NavigationOptions, N as NavigateEvent, b as NavigationCurrentEntryChangeEvent, h as NavigationTransition, i as NavigationUpdateCurrentEntryOptions, f as NavigationReloadOptions } from '../navigation_types.d-u4EOrrdZ.js';
27
10
 
28
11
  /**
29
- * This API should be removed. But doing so seems to break `google3` and so it requires a bit of
30
- * investigation.
12
+ * Wraps a test function in an asynchronous test zone. The test will automatically
13
+ * complete when all asynchronous calls within this zone are done. Can be used
14
+ * to wrap an {@link inject} call.
31
15
  *
32
- * A work around is to mark it as `@codeGenApi` for now and investigate later.
16
+ * Example:
33
17
  *
34
- * @codeGenApi
18
+ * ```ts
19
+ * it('...', waitForAsync(inject([AClass], (object) => {
20
+ * object.doSomething.then(() => {
21
+ * expect(...);
22
+ * })
23
+ * })));
24
+ * ```
25
+ *
26
+ * @publicApi
27
+ */
28
+ declare function waitForAsync(fn: Function): (done: any) => any;
29
+
30
+ /**
31
+ * Represents an individual defer block for testing purposes.
32
+ *
33
+ * @publicApi
35
34
  */
36
- export declare const __core_private_testing_placeholder__ = "";
35
+ declare class DeferBlockFixture {
36
+ private block;
37
+ private componentFixture;
38
+ /** @nodoc */
39
+ constructor(block: _DeferBlockDetails, componentFixture: ComponentFixture<unknown>);
40
+ /**
41
+ * Renders the specified state of the defer fixture.
42
+ * @param state the defer state to render
43
+ */
44
+ render(state: _DeferBlockState): Promise<void>;
45
+ /**
46
+ * Retrieves all nested child defer block fixtures
47
+ * in a given defer block.
48
+ */
49
+ getDeferBlocks(): Promise<DeferBlockFixture[]>;
50
+ }
37
51
 
38
52
  /**
39
53
  * Fixture for debugging and testing a component.
40
54
  *
41
55
  * @publicApi
42
56
  */
43
- export declare class ComponentFixture<T> {
57
+ declare class ComponentFixture<T> {
44
58
  componentRef: ComponentRef<T>;
45
59
  /**
46
60
  * The DebugElement associated with the root element of this component.
@@ -121,48 +135,12 @@ export declare class ComponentFixture<T> {
121
135
  }
122
136
 
123
137
  /**
124
- * @publicApi
125
- */
126
- export declare const ComponentFixtureAutoDetect: InjectionToken<boolean>;
127
-
128
- /**
129
- * @publicApi
130
- */
131
- export declare const ComponentFixtureNoNgZone: InjectionToken<boolean>;
132
-
133
- export { DeferBlockBehavior }
134
-
135
- /**
136
- * Represents an individual defer block for testing purposes.
137
- *
138
- * @publicApi
139
- */
140
- export declare class DeferBlockFixture {
141
- private block;
142
- private componentFixture;
143
- /** @nodoc */
144
- constructor(block: ɵDeferBlockDetails, componentFixture: ComponentFixture<unknown>);
145
- /**
146
- * Renders the specified state of the defer fixture.
147
- * @param state the defer state to render
148
- */
149
- render(state: DeferBlockState): Promise<void>;
150
- /**
151
- * Retrieves all nested child defer block fixtures
152
- * in a given defer block.
153
- */
154
- getDeferBlocks(): Promise<DeferBlockFixture[]>;
155
- }
156
-
157
- export { DeferBlockState }
158
-
159
- /**
160
- * Discard all remaining periodic tasks.
138
+ * Clears out the shared fake async zone for a test.
139
+ * To be called in a global `beforeEach`.
161
140
  *
162
141
  * @publicApi
163
142
  */
164
- export declare function discardPeriodicTasks(): void;
165
-
143
+ declare function resetFakeAsyncZone(): void;
166
144
  /**
167
145
  * Wraps a function to be executed in the `fakeAsync` zone:
168
146
  * - Microtasks are manually executed by calling `flushMicrotasks()`.
@@ -187,46 +165,76 @@ export declare function discardPeriodicTasks(): void;
187
165
  *
188
166
  * @publicApi
189
167
  */
190
- export declare function fakeAsync(fn: Function, options?: {
168
+ declare function fakeAsync(fn: Function, options?: {
191
169
  flush?: boolean;
192
170
  }): (...args: any[]) => any;
193
-
194
- /**
195
- * Fake equivalent of `NavigationHistoryEntry`.
196
- */
197
- declare class FakeNavigationHistoryEntry implements NavigationHistoryEntry {
198
- readonly url: string | null;
199
- readonly sameDocument: boolean;
200
- readonly id: string;
201
- readonly key: string;
202
- readonly index: number;
203
- private readonly state;
204
- private readonly historyState;
205
- ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null;
206
- constructor(url: string | null, { id, key, index, sameDocument, state, historyState, }: {
207
- id: string;
208
- key: string;
209
- index: number;
210
- sameDocument: boolean;
211
- historyState: unknown;
212
- state?: unknown;
213
- });
214
- getState(): unknown;
215
- getHistoryState(): unknown;
216
- addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: AddEventListenerOptions | boolean): void;
217
- removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: EventListenerOptions | boolean): void;
218
- dispatchEvent(event: Event): boolean;
219
- }
220
-
221
171
  /**
222
- * Fake equivalent of the `NavigationResult` interface with
223
- * `FakeNavigationHistoryEntry`.
172
+ * Simulates the asynchronous passage of time for the timers in the `fakeAsync` zone.
173
+ *
174
+ * The microtasks queue is drained at the very start of this function and after any timer callback
175
+ * has been executed.
176
+ *
177
+ * @param millis The number of milliseconds to advance the virtual timer.
178
+ * @param tickOptions The options to pass to the `tick()` function.
179
+ *
180
+ * @usageNotes
181
+ *
182
+ * The `tick()` option is a flag called `processNewMacroTasksSynchronously`,
183
+ * which determines whether or not to invoke new macroTasks.
184
+ *
185
+ * If you provide a `tickOptions` object, but do not specify a
186
+ * `processNewMacroTasksSynchronously` property (`tick(100, {})`),
187
+ * then `processNewMacroTasksSynchronously` defaults to true.
188
+ *
189
+ * If you omit the `tickOptions` parameter (`tick(100))`), then
190
+ * `tickOptions` defaults to `{processNewMacroTasksSynchronously: true}`.
191
+ *
192
+ * ### Example
193
+ *
194
+ * {@example core/testing/ts/fake_async.ts region='basic'}
195
+ *
196
+ * The following example includes a nested timeout (new macroTask), and
197
+ * the `tickOptions` parameter is allowed to default. In this case,
198
+ * `processNewMacroTasksSynchronously` defaults to true, and the nested
199
+ * function is executed on each tick.
200
+ *
201
+ * ```ts
202
+ * it ('test with nested setTimeout', fakeAsync(() => {
203
+ * let nestedTimeoutInvoked = false;
204
+ * function funcWithNestedTimeout() {
205
+ * setTimeout(() => {
206
+ * nestedTimeoutInvoked = true;
207
+ * });
208
+ * };
209
+ * setTimeout(funcWithNestedTimeout);
210
+ * tick();
211
+ * expect(nestedTimeoutInvoked).toBe(true);
212
+ * }));
213
+ * ```
214
+ *
215
+ * In the following case, `processNewMacroTasksSynchronously` is explicitly
216
+ * set to false, so the nested timeout function is not invoked.
217
+ *
218
+ * ```ts
219
+ * it ('test with nested setTimeout', fakeAsync(() => {
220
+ * let nestedTimeoutInvoked = false;
221
+ * function funcWithNestedTimeout() {
222
+ * setTimeout(() => {
223
+ * nestedTimeoutInvoked = true;
224
+ * });
225
+ * };
226
+ * setTimeout(funcWithNestedTimeout);
227
+ * tick(0, {processNewMacroTasksSynchronously: false});
228
+ * expect(nestedTimeoutInvoked).toBe(false);
229
+ * }));
230
+ * ```
231
+ *
232
+ *
233
+ * @publicApi
224
234
  */
225
- declare interface FakeNavigationResult extends NavigationResult {
226
- readonly committed: Promise<FakeNavigationHistoryEntry>;
227
- readonly finished: Promise<FakeNavigationHistoryEntry>;
228
- }
229
-
235
+ declare function tick(millis?: number, tickOptions?: {
236
+ processNewMacroTasksSynchronously: boolean;
237
+ }): void;
230
238
  /**
231
239
  * Flushes any pending microtasks and simulates the asynchronous passage of time for the timers in
232
240
  * the `fakeAsync` zone by
@@ -238,222 +246,142 @@ declare interface FakeNavigationResult extends NavigationResult {
238
246
  *
239
247
  * @publicApi
240
248
  */
241
- export declare function flush(maxTurns?: number): number;
242
-
249
+ declare function flush(maxTurns?: number): number;
243
250
  /**
244
- * Flush any pending microtasks.
251
+ * Discard all remaining periodic tasks.
245
252
  *
246
253
  * @publicApi
247
254
  */
248
- export declare function flushMicrotasks(): void;
249
-
255
+ declare function discardPeriodicTasks(): void;
250
256
  /**
251
- * Returns a singleton of the `TestBed` class.
257
+ * Flush any pending microtasks.
252
258
  *
253
259
  * @publicApi
254
260
  */
255
- export declare function getTestBed(): TestBed;
261
+ declare function flushMicrotasks(): void;
256
262
 
257
263
  /**
258
- * Allows injecting dependencies in `beforeEach()` and `it()`. Note: this function
259
- * (imported from the `@angular/core/testing` package) can **only** be used to inject dependencies
260
- * in tests. To inject dependencies in your application code, use the [`inject`](api/core/inject)
261
- * function from the `@angular/core` package instead.
262
- *
263
- * Example:
264
- *
265
- * ```ts
266
- * beforeEach(inject([Dependency, AClass], (dep, object) => {
267
- * // some code that uses `dep` and `object`
268
- * // ...
269
- * }));
270
- *
271
- * it('...', inject([AClass], (object) => {
272
- * object.doSomething();
273
- * expect(...);
274
- * })
275
- * ```
264
+ * Type used for modifications to metadata
276
265
  *
277
266
  * @publicApi
278
267
  */
279
- export declare function inject(tokens: any[], fn: Function): () => any;
268
+ type MetadataOverride<T> = {
269
+ add?: Partial<T>;
270
+ remove?: Partial<T>;
271
+ set?: Partial<T>;
272
+ };
280
273
 
281
274
  /**
275
+ * An abstract class for inserting the root test component element in a platform independent way.
276
+ *
282
277
  * @publicApi
283
278
  */
284
- export declare class InjectSetupWrapper {
285
- private _moduleDef;
286
- constructor(_moduleDef: () => TestModuleMetadata);
287
- private _addModule;
288
- inject(tokens: any[], fn: Function): () => any;
279
+ declare class TestComponentRenderer {
280
+ insertRootElement(rootElementId: string): void;
281
+ removeAllRootElements?(): void;
289
282
  }
290
-
291
-
292
283
  /**
293
- * Type used for modifications to metadata
294
- *
295
284
  * @publicApi
296
285
  */
297
- export declare type MetadataOverride<T> = {
298
- add?: Partial<T>;
299
- remove?: Partial<T>;
300
- set?: Partial<T>;
301
- };
302
-
286
+ declare const ComponentFixtureAutoDetect: InjectionToken<boolean>;
303
287
  /**
304
- * Configures the test module teardown behavior in `TestBed`.
305
288
  * @publicApi
306
289
  */
307
- export declare interface ModuleTeardownOptions {
308
- /** Whether the test module should be destroyed after every test. Defaults to `true`. */
309
- destroyAfterEach: boolean;
310
- /** Whether errors during test module destruction should be re-thrown. Defaults to `true`. */
311
- rethrowErrors?: boolean;
312
- }
313
-
314
- declare class NavigateEvent extends Event {
315
- constructor(type: string, eventInit?: NavigateEventInit);
316
- readonly navigationType: NavigationTypeString;
317
- readonly canIntercept: boolean;
318
- readonly userInitiated: boolean;
319
- readonly hashChange: boolean;
320
- readonly destination: NavigationDestination;
321
- readonly signal: AbortSignal;
322
- readonly formData: FormData | null;
323
- readonly downloadRequest: string | null;
324
- readonly info?: unknown;
325
- intercept(options?: NavigationInterceptOptions): void;
326
- scroll(): void;
327
- }
328
-
329
- declare interface NavigateEventInit extends EventInit {
330
- navigationType?: NavigationTypeString;
331
- canIntercept?: boolean;
332
- userInitiated?: boolean;
333
- hashChange?: boolean;
334
- destination: NavigationDestination;
335
- signal: AbortSignal;
336
- formData?: FormData | null;
337
- downloadRequest?: string | null;
338
- info?: unknown;
339
- }
340
-
341
- declare class Navigation extends EventTarget {
342
- entries(): NavigationHistoryEntry[];
343
- readonly currentEntry: NavigationHistoryEntry | null;
344
- updateCurrentEntry(options: NavigationUpdateCurrentEntryOptions): void;
345
- readonly transition: NavigationTransition | null;
346
- readonly canGoBack: boolean;
347
- readonly canGoForward: boolean;
348
- navigate(url: string, options?: NavigationNavigateOptions): NavigationResult;
349
- reload(options?: NavigationReloadOptions): NavigationResult;
350
- traverseTo(key: string, options?: NavigationOptions): NavigationResult;
351
- back(options?: NavigationOptions): NavigationResult;
352
- forward(options?: NavigationOptions): NavigationResult;
353
- onnavigate: ((this: Navigation, ev: NavigateEvent) => any) | null;
354
- onnavigatesuccess: ((this: Navigation, ev: Event) => any) | null;
355
- onnavigateerror: ((this: Navigation, ev: ErrorEvent) => any) | null;
356
- oncurrententrychange: ((this: Navigation, ev: NavigationCurrentEntryChangeEvent) => any) | null;
357
- addEventListener<K extends keyof NavigationEventMap>(type: K, listener: (this: Navigation, ev: NavigationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
358
- addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
359
- removeEventListener<K extends keyof NavigationEventMap>(type: K, listener: (this: Navigation, ev: NavigationEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
360
- removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
361
- }
362
-
363
- declare class NavigationCurrentEntryChangeEvent extends Event {
364
- constructor(type: string, eventInit?: NavigationCurrentEntryChangeEventInit);
365
- readonly navigationType: NavigationTypeString | null;
366
- readonly from: NavigationHistoryEntry;
367
- }
368
-
369
- declare interface NavigationCurrentEntryChangeEventInit extends EventInit {
370
- navigationType?: NavigationTypeString | null;
371
- from: NavigationHistoryEntry;
372
- }
373
-
374
- declare class NavigationDestination {
375
- readonly url: string;
376
- readonly key: string | null;
377
- readonly id: string | null;
378
- readonly index: number;
379
- readonly sameDocument: boolean;
380
- getState(): unknown;
381
- }
382
-
383
-
384
- declare interface NavigationEventMap {
385
- navigate: NavigateEvent;
386
- navigatesuccess: Event;
387
- navigateerror: ErrorEvent;
388
- currententrychange: NavigationCurrentEntryChangeEvent;
389
- }
390
-
391
- declare class NavigationHistoryEntry extends EventTarget {
392
- readonly key: string;
393
- readonly id: string;
394
- readonly url: string | null;
395
- readonly index: number;
396
- readonly sameDocument: boolean;
397
- getState(): unknown;
398
- ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null;
399
- addEventListener<K extends keyof NavigationHistoryEntryEventMap>(type: K, listener: (this: NavigationHistoryEntry, ev: NavigationHistoryEntryEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
400
- addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
401
- removeEventListener<K extends keyof NavigationHistoryEntryEventMap>(type: K, listener: (this: NavigationHistoryEntry, ev: NavigationHistoryEntryEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
402
- removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
403
- }
404
-
405
- declare interface NavigationHistoryEntryEventMap {
406
- dispose: Event;
407
- }
408
-
409
- declare interface NavigationInterceptOptions {
410
- handler?: () => Promise<void>;
411
- focusReset?: 'after-transition' | 'manual';
412
- scroll?: 'after-transition' | 'manual';
413
- }
414
-
415
- declare interface NavigationNavigateOptions extends NavigationOptions {
416
- state?: unknown;
417
- history?: 'auto' | 'push' | 'replace';
418
- }
419
-
420
- declare interface NavigationOptions {
421
- info?: unknown;
422
- }
423
-
424
- declare interface NavigationReloadOptions extends NavigationOptions {
425
- state?: unknown;
290
+ declare const ComponentFixtureNoNgZone: InjectionToken<boolean>;
291
+ /**
292
+ * @publicApi
293
+ */
294
+ interface TestModuleMetadata {
295
+ providers?: any[];
296
+ declarations?: any[];
297
+ imports?: any[];
298
+ schemas?: Array<SchemaMetadata | any[]>;
299
+ teardown?: ModuleTeardownOptions;
300
+ /**
301
+ * Whether NG0304 runtime errors should be thrown when unknown elements are present in component's
302
+ * template. Defaults to `false`, where the error is simply logged. If set to `true`, the error is
303
+ * thrown.
304
+ * @see [NG8001](/errors/NG8001) for the description of the problem and how to fix it
305
+ */
306
+ errorOnUnknownElements?: boolean;
307
+ /**
308
+ * Whether errors should be thrown when unknown properties are present in component's template.
309
+ * Defaults to `false`, where the error is simply logged.
310
+ * If set to `true`, the error is thrown.
311
+ * @see [NG8002](/errors/NG8002) for the description of the error and how to fix it
312
+ */
313
+ errorOnUnknownProperties?: boolean;
314
+ /**
315
+ * Whether errors that happen during application change detection should be rethrown.
316
+ *
317
+ * When `true`, errors that are caught during application change detection will
318
+ * be reported to the `ErrorHandler` and rethrown to prevent them from going
319
+ * unnoticed in tests.
320
+ *
321
+ * When `false`, errors are only forwarded to the `ErrorHandler`, which by default
322
+ * simply logs them to the console.
323
+ *
324
+ * Defaults to `true`.
325
+ */
326
+ rethrowApplicationErrors?: boolean;
327
+ /**
328
+ * Whether defer blocks should behave with manual triggering or play through normally.
329
+ * Defaults to `manual`.
330
+ */
331
+ deferBlockBehavior?: _DeferBlockBehavior;
426
332
  }
427
-
428
- declare interface NavigationResult {
429
- committed: Promise<NavigationHistoryEntry>;
430
- finished: Promise<NavigationHistoryEntry>;
333
+ /**
334
+ * @publicApi
335
+ */
336
+ interface TestEnvironmentOptions {
337
+ /**
338
+ * Configures the test module teardown behavior in `TestBed`.
339
+ */
340
+ teardown?: ModuleTeardownOptions;
341
+ /**
342
+ * Whether errors should be thrown when unknown elements are present in component's template.
343
+ * Defaults to `false`, where the error is simply logged.
344
+ * If set to `true`, the error is thrown.
345
+ * @see [NG8001](/errors/NG8001) for the description of the error and how to fix it
346
+ */
347
+ errorOnUnknownElements?: boolean;
348
+ /**
349
+ * Whether errors should be thrown when unknown properties are present in component's template.
350
+ * Defaults to `false`, where the error is simply logged.
351
+ * If set to `true`, the error is thrown.
352
+ * @see [NG8002](/errors/NG8002) for the description of the error and how to fix it
353
+ */
354
+ errorOnUnknownProperties?: boolean;
431
355
  }
432
-
433
- declare class NavigationTransition {
434
- readonly navigationType: NavigationTypeString;
435
- readonly from: NavigationHistoryEntry;
436
- readonly finished: Promise<void>;
356
+ /**
357
+ * Configures the test module teardown behavior in `TestBed`.
358
+ * @publicApi
359
+ */
360
+ interface ModuleTeardownOptions {
361
+ /** Whether the test module should be destroyed after every test. Defaults to `true`. */
362
+ destroyAfterEach: boolean;
363
+ /** Whether errors during test module destruction should be re-thrown. Defaults to `true`. */
364
+ rethrowErrors?: boolean;
437
365
  }
438
366
 
439
- declare type NavigationTypeString = 'reload' | 'push' | 'replace' | 'traverse';
440
-
441
- declare interface NavigationUpdateCurrentEntryOptions {
442
- state: unknown;
367
+ /**
368
+ * Static methods implemented by the `TestBed`.
369
+ *
370
+ * @publicApi
371
+ */
372
+ interface TestBedStatic extends TestBed {
373
+ new (...args: any[]): TestBed;
443
374
  }
444
-
445
375
  /**
446
- * Clears out the shared fake async zone for a test.
447
- * To be called in a global `beforeEach`.
376
+ * Returns a singleton of the `TestBed` class.
448
377
  *
449
378
  * @publicApi
450
379
  */
451
- export declare function resetFakeAsyncZone(): void;
452
-
380
+ declare function getTestBed(): TestBed;
453
381
  /**
454
382
  * @publicApi
455
383
  */
456
- export declare interface TestBed {
384
+ interface TestBed {
457
385
  get platform(): PlatformRef;
458
386
  get ngModule(): Type<any> | Type<any>[];
459
387
  /**
@@ -531,7 +459,6 @@ export declare interface TestBed {
531
459
  */
532
460
  flushEffects(): void;
533
461
  }
534
-
535
462
  /**
536
463
  * @description
537
464
  * Configures and initializes environment for unit testing and provides methods for
@@ -541,195 +468,72 @@ export declare interface TestBed {
541
468
  *
542
469
  * @publicApi
543
470
  */
544
- export declare const TestBed: TestBedStatic;
545
-
471
+ declare const TestBed: TestBedStatic;
546
472
  /**
547
- * Static methods implemented by the `TestBed`.
473
+ * Allows injecting dependencies in `beforeEach()` and `it()`. Note: this function
474
+ * (imported from the `@angular/core/testing` package) can **only** be used to inject dependencies
475
+ * in tests. To inject dependencies in your application code, use the [`inject`](api/core/inject)
476
+ * function from the `@angular/core` package instead.
548
477
  *
549
- * @publicApi
550
- */
551
- export declare interface TestBedStatic extends TestBed {
552
- new (...args: any[]): TestBed;
553
- }
554
-
555
- /**
556
- * An abstract class for inserting the root test component element in a platform independent way.
478
+ * Example:
479
+ *
480
+ * ```ts
481
+ * beforeEach(inject([Dependency, AClass], (dep, object) => {
482
+ * // some code that uses `dep` and `object`
483
+ * // ...
484
+ * }));
485
+ *
486
+ * it('...', inject([AClass], (object) => {
487
+ * object.doSomething();
488
+ * expect(...);
489
+ * })
490
+ * ```
557
491
  *
558
492
  * @publicApi
559
493
  */
560
- export declare class TestComponentRenderer {
561
- insertRootElement(rootElementId: string): void;
562
- removeAllRootElements?(): void;
563
- }
564
-
565
- /**
566
- * @publicApi
567
- */
568
- export declare interface TestEnvironmentOptions {
569
- /**
570
- * Configures the test module teardown behavior in `TestBed`.
571
- */
572
- teardown?: ModuleTeardownOptions;
573
- /**
574
- * Whether errors should be thrown when unknown elements are present in component's template.
575
- * Defaults to `false`, where the error is simply logged.
576
- * If set to `true`, the error is thrown.
577
- * @see [NG8001](/errors/NG8001) for the description of the error and how to fix it
578
- */
579
- errorOnUnknownElements?: boolean;
580
- /**
581
- * Whether errors should be thrown when unknown properties are present in component's template.
582
- * Defaults to `false`, where the error is simply logged.
583
- * If set to `true`, the error is thrown.
584
- * @see [NG8002](/errors/NG8002) for the description of the error and how to fix it
585
- */
586
- errorOnUnknownProperties?: boolean;
587
- }
588
-
494
+ declare function inject(tokens: any[], fn: Function): () => any;
589
495
  /**
590
496
  * @publicApi
591
497
  */
592
- export declare interface TestModuleMetadata {
593
- providers?: any[];
594
- declarations?: any[];
595
- imports?: any[];
596
- schemas?: Array<SchemaMetadata | any[]>;
597
- teardown?: ModuleTeardownOptions;
598
- /**
599
- * Whether NG0304 runtime errors should be thrown when unknown elements are present in component's
600
- * template. Defaults to `false`, where the error is simply logged. If set to `true`, the error is
601
- * thrown.
602
- * @see [NG8001](/errors/NG8001) for the description of the problem and how to fix it
603
- */
604
- errorOnUnknownElements?: boolean;
605
- /**
606
- * Whether errors should be thrown when unknown properties are present in component's template.
607
- * Defaults to `false`, where the error is simply logged.
608
- * If set to `true`, the error is thrown.
609
- * @see [NG8002](/errors/NG8002) for the description of the error and how to fix it
610
- */
611
- errorOnUnknownProperties?: boolean;
612
- /**
613
- * Whether errors that happen during application change detection should be rethrown.
614
- *
615
- * When `true`, errors that are caught during application change detection will
616
- * be reported to the `ErrorHandler` and rethrown to prevent them from going
617
- * unnoticed in tests.
618
- *
619
- * When `false`, errors are only forwarded to the `ErrorHandler`, which by default
620
- * simply logs them to the console.
621
- *
622
- * Defaults to `true`.
623
- */
624
- rethrowApplicationErrors?: boolean;
625
- /**
626
- * Whether defer blocks should behave with manual triggering or play through normally.
627
- * Defaults to `manual`.
628
- */
629
- deferBlockBehavior?: DeferBlockBehavior;
498
+ declare class InjectSetupWrapper {
499
+ private _moduleDef;
500
+ constructor(_moduleDef: () => TestModuleMetadata);
501
+ private _addModule;
502
+ inject(tokens: any[], fn: Function): () => any;
630
503
  }
631
-
632
504
  /**
633
- * Simulates the asynchronous passage of time for the timers in the `fakeAsync` zone.
634
- *
635
- * The microtasks queue is drained at the very start of this function and after any timer callback
636
- * has been executed.
637
- *
638
- * @param millis The number of milliseconds to advance the virtual timer.
639
- * @param tickOptions The options to pass to the `tick()` function.
640
- *
641
- * @usageNotes
642
- *
643
- * The `tick()` option is a flag called `processNewMacroTasksSynchronously`,
644
- * which determines whether or not to invoke new macroTasks.
645
- *
646
- * If you provide a `tickOptions` object, but do not specify a
647
- * `processNewMacroTasksSynchronously` property (`tick(100, {})`),
648
- * then `processNewMacroTasksSynchronously` defaults to true.
649
- *
650
- * If you omit the `tickOptions` parameter (`tick(100))`), then
651
- * `tickOptions` defaults to `{processNewMacroTasksSynchronously: true}`.
652
- *
653
- * ### Example
654
- *
655
- * {@example core/testing/ts/fake_async.ts region='basic'}
656
- *
657
- * The following example includes a nested timeout (new macroTask), and
658
- * the `tickOptions` parameter is allowed to default. In this case,
659
- * `processNewMacroTasksSynchronously` defaults to true, and the nested
660
- * function is executed on each tick.
661
- *
662
- * ```ts
663
- * it ('test with nested setTimeout', fakeAsync(() => {
664
- * let nestedTimeoutInvoked = false;
665
- * function funcWithNestedTimeout() {
666
- * setTimeout(() => {
667
- * nestedTimeoutInvoked = true;
668
- * });
669
- * };
670
- * setTimeout(funcWithNestedTimeout);
671
- * tick();
672
- * expect(nestedTimeoutInvoked).toBe(true);
673
- * }));
674
- * ```
675
- *
676
- * In the following case, `processNewMacroTasksSynchronously` is explicitly
677
- * set to false, so the nested timeout function is not invoked.
678
- *
679
- * ```ts
680
- * it ('test with nested setTimeout', fakeAsync(() => {
681
- * let nestedTimeoutInvoked = false;
682
- * function funcWithNestedTimeout() {
683
- * setTimeout(() => {
684
- * nestedTimeoutInvoked = true;
685
- * });
686
- * };
687
- * setTimeout(funcWithNestedTimeout);
688
- * tick(0, {processNewMacroTasksSynchronously: false});
689
- * expect(nestedTimeoutInvoked).toBe(false);
690
- * }));
691
- * ```
692
- *
693
- *
694
505
  * @publicApi
695
506
  */
696
- export declare function tick(millis?: number, tickOptions?: {
697
- processNewMacroTasksSynchronously: boolean;
698
- }): void;
699
-
507
+ declare function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper;
508
+ declare function withModule(moduleDef: TestModuleMetadata, fn: Function): () => any;
700
509
 
701
510
  /**
702
- * Wraps a test function in an asynchronous test zone. The test will automatically
703
- * complete when all asynchronous calls within this zone are done. Can be used
704
- * to wrap an {@link inject} call.
705
- *
706
- * Example:
511
+ * This API should be removed. But doing so seems to break `google3` and so it requires a bit of
512
+ * investigation.
707
513
  *
708
- * ```ts
709
- * it('...', waitForAsync(inject([AClass], (object) => {
710
- * object.doSomething.then(() => {
711
- * expect(...);
712
- * })
713
- * })));
714
- * ```
514
+ * A work around is to mark it as `@codeGenApi` for now and investigate later.
715
515
  *
716
- * @publicApi
717
- */
718
- export declare function waitForAsync(fn: Function): (done: any) => any;
719
-
720
- /**
721
- * @publicApi
516
+ * @codeGenApi
722
517
  */
723
- export declare function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper;
518
+ declare const __core_private_testing_placeholder__ = "";
724
519
 
725
- export declare function withModule(moduleDef: TestModuleMetadata, fn: Function): () => any;
520
+ declare class MetadataOverrider {
521
+ private _references;
522
+ /**
523
+ * Creates a new instance for the given metadata class
524
+ * based on an old instance and overrides.
525
+ */
526
+ overrideMetadata<C extends T, T>(metadataClass: {
527
+ new (options: T): C;
528
+ }, oldMetadata: C, override: MetadataOverride<T>): C;
529
+ }
726
530
 
727
531
  /**
728
532
  * Fake implementation of user agent history and navigation behavior. This is a
729
533
  * high-fidelity implementation of browser behavior that attempts to emulate
730
534
  * things like traversal delay.
731
535
  */
732
- export declare class ɵFakeNavigation implements Navigation {
536
+ declare class FakeNavigation implements Navigation {
733
537
  private readonly window;
734
538
  /**
735
539
  * The fake implementation of an entries array. Only same-document entries
@@ -740,10 +544,6 @@ export declare class ɵFakeNavigation implements Navigation {
740
544
  * The current active entry index into `entriesArr`.
741
545
  */
742
546
  private currentEntryIndex;
743
- /**
744
- * The current navigate event.
745
- */
746
- private navigateEvent;
747
547
  /**
748
548
  * A Map of pending traversals, so that traversals to the same entry can be
749
549
  * re-used.
@@ -766,8 +566,6 @@ export declare class ɵFakeNavigation implements Navigation {
766
566
  private synchronousTraversals;
767
567
  /** Whether to allow a call to setInitialEntryForTesting. */
768
568
  private canSetInitialEntry;
769
- /** `EventTarget` to dispatch events. */
770
- private eventTarget;
771
569
  /** The next unique id for created entries. Replace recreates this id. */
772
570
  private nextId;
773
571
  /** The next unique key for created entries. Replace inherits this id. */
@@ -830,12 +628,25 @@ export declare class ɵFakeNavigation implements Navigation {
830
628
  isDisposed(): boolean;
831
629
  /** Implementation for all navigations and traversals. */
832
630
  private userAgentNavigate;
833
- /** Implementation to commit a navigation. */
834
- private userAgentCommit;
835
- /** Implementation for a push or replace navigation. */
836
- private userAgentPushOrReplace;
837
- /** Implementation for a traverse navigation. */
631
+ /**
632
+ * Implementation for a push or replace navigation.
633
+ * https://whatpr.org/html/10919/browsing-the-web.html#url-and-history-update-steps
634
+ * https://whatpr.org/html/10919/nav-history-apis.html#update-the-navigation-api-entries-for-a-same-document-navigation
635
+ */
636
+ private urlAndHistoryUpdateSteps;
637
+ /**
638
+ * Implementation for a traverse navigation.
639
+ *
640
+ * https://whatpr.org/html/10919/browsing-the-web.html#apply-the-traverse-history-step
641
+ * ...
642
+ * > Let updateDocument be an algorithm step which performs update document for history step application given targetEntry's document, targetEntry, changingNavigableContinuation's update-only, scriptHistoryLength, scriptHistoryIndex, navigationType, entriesForNavigationAPI, and previousEntry.
643
+ * > If targetEntry's document is equal to displayedDocument, then perform updateDocument.
644
+ * https://whatpr.org/html/10919/browsing-the-web.html#update-document-for-history-step-application
645
+ * which then goes to https://whatpr.org/html/10919/nav-history-apis.html#update-the-navigation-api-entries-for-a-same-document-navigation
646
+ */
838
647
  private userAgentTraverse;
648
+ /** https://whatpr.org/html/10919/nav-history-apis.html#update-the-navigation-api-entries-for-a-same-document-navigation */
649
+ private updateNavigationEntriesForSameDocumentNavigation;
839
650
  /** Utility method for finding entries with the given `key`. */
840
651
  private findEntry;
841
652
  set onnavigate(_handler: ((this: Navigation, ev: NavigateEvent) => any) | null);
@@ -848,20 +659,47 @@ export declare class ɵFakeNavigation implements Navigation {
848
659
  get onnavigatesuccess(): ((this: Navigation, ev: Event) => any) | null;
849
660
  set onnavigateerror(_handler: ((this: Navigation, ev: ErrorEvent) => any) | null);
850
661
  get onnavigateerror(): ((this: Navigation, ev: ErrorEvent) => any) | null;
662
+ private _transition;
851
663
  get transition(): NavigationTransition | null;
852
664
  updateCurrentEntry(_options: NavigationUpdateCurrentEntryOptions): void;
853
665
  reload(_options?: NavigationReloadOptions): NavigationResult;
854
666
  }
855
-
856
- export declare class ɵMetadataOverrider {
857
- private _references;
858
- /**
859
- * Creates a new instance for the given metadata class
860
- * based on an old instance and overrides.
861
- */
862
- overrideMetadata<C extends T, T>(metadataClass: {
863
- new (options: T): C;
864
- }, oldMetadata: C, override: MetadataOverride<T>): C;
667
+ /**
668
+ * Fake equivalent of the `NavigationResult` interface with
669
+ * `FakeNavigationHistoryEntry`.
670
+ */
671
+ interface FakeNavigationResult extends NavigationResult {
672
+ readonly committed: Promise<FakeNavigationHistoryEntry>;
673
+ readonly finished: Promise<FakeNavigationHistoryEntry>;
674
+ }
675
+ /**
676
+ * Fake equivalent of `NavigationHistoryEntry`.
677
+ */
678
+ declare class FakeNavigationHistoryEntry implements NavigationHistoryEntry {
679
+ private eventTarget;
680
+ readonly url: string | null;
681
+ readonly sameDocument: boolean;
682
+ readonly id: string;
683
+ readonly key: string;
684
+ readonly index: number;
685
+ private readonly state;
686
+ private readonly historyState;
687
+ ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null;
688
+ constructor(eventTarget: EventTarget, url: string | null, { id, key, index, sameDocument, state, historyState, }: {
689
+ id: string;
690
+ key: string;
691
+ index: number;
692
+ sameDocument: boolean;
693
+ historyState: unknown;
694
+ state?: unknown;
695
+ });
696
+ getState(): unknown;
697
+ getHistoryState(): unknown;
698
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: AddEventListenerOptions | boolean): void;
699
+ removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: EventListenerOptions | boolean): void;
700
+ dispatchEvent(event: Event): boolean;
701
+ /** internal */
702
+ dispose(): void;
865
703
  }
866
704
 
867
- export { }
705
+ export { ComponentFixture, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, DeferBlockFixture, InjectSetupWrapper, type MetadataOverride, type ModuleTeardownOptions, TestBed, type TestBedStatic, TestComponentRenderer, type TestEnvironmentOptions, type TestModuleMetadata, __core_private_testing_placeholder__, discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, getTestBed, inject, resetFakeAsyncZone, tick, waitForAsync, withModule, FakeNavigation as ɵFakeNavigation, MetadataOverrider as ɵMetadataOverrider };