@angular/core 20.0.0-next.0 → 20.0.0-next.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 (52) hide show
  1. package/fesm2022/core.mjs +3307 -4479
  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 -33
  10. package/fesm2022/rxjs-interop.mjs.map +1 -1
  11. package/fesm2022/testing.mjs +392 -250
  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 +14339 -15134
  16. package/navigation_types.d-u4EOrrdZ.d.ts +121 -0
  17. package/package.json +11 -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 +72 -92
  22. package/schematics/bundles/{apply_import_manager-0959b78c.js → apply_import_manager-CyRT0UvU.js} +13 -17
  23. package/schematics/bundles/{checker-cf6f7980.js → checker-DF8ZaFW5.js} +3363 -1289
  24. package/schematics/bundles/cleanup-unused-imports.js +22 -28
  25. package/schematics/bundles/{compiler_host-cc1379e9.js → compiler_host-Da636uJ8.js} +20 -24
  26. package/schematics/bundles/control-flow-migration.js +82 -39
  27. package/schematics/bundles/{imports-31a38653.js → imports-CIX-JgAN.js} +10 -15
  28. package/schematics/bundles/{index-42d84d69.js → index-DnkWgagp.js} +56 -60
  29. package/schematics/bundles/{index-6675d6bc.js → index-vGJcp5M7.js} +5 -5
  30. package/schematics/bundles/inject-flags.js +181 -0
  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-5089e4ef.js → migrate_ts_type_references-DtkOnnv0.js} +113 -120
  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/{program-362689f0.js → program-BZk27Ndu.js} +846 -2653
  38. package/schematics/bundles/{project_paths-7d2daa1e.js → project_paths-Jtbi76Bs.js} +26 -24
  39. package/schematics/bundles/{project_tsconfig_paths-6c9cde78.js → project_tsconfig_paths-CDVxT6Ov.js} +2 -2
  40. package/schematics/bundles/{property_name-42030525.js → property_name-BBwFuqMe.js} +4 -8
  41. package/schematics/bundles/route-lazy-loading.js +36 -42
  42. package/schematics/bundles/self-closing-tags-migration.js +55 -45
  43. package/schematics/bundles/signal-input-migration.js +61 -68
  44. package/schematics/bundles/signal-queries-migration.js +48 -55
  45. package/schematics/bundles/signals.js +10 -12
  46. package/schematics/bundles/standalone-migration.js +179 -185
  47. package/schematics/migrations.json +4 -15
  48. package/testing/index.d.ts +309 -478
  49. package/weak_ref.d-ttyj86RV.d.ts +9 -0
  50. package/schematics/bundles/explicit-standalone-flag.js +0 -184
  51. package/schematics/bundles/pending-tasks.js +0 -103
  52. package/schematics/bundles/provide-initializer.js +0 -186
@@ -1,46 +1,60 @@
1
1
  /**
2
- * @license Angular v20.0.0-next.0
3
- * (c) 2010-2024 Google LLC. https://angular.io/
2
+ * @license Angular v20.0.0-next.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, 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
35
27
  */
36
- export declare const __core_private_testing_placeholder__ = "";
28
+ declare function waitForAsync(fn: Function): (done: any) => any;
29
+
30
+ /**
31
+ * Represents an individual defer block for testing purposes.
32
+ *
33
+ * @publicApi
34
+ */
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.
@@ -70,7 +84,6 @@ export declare class ComponentFixture<T> {
70
84
  private readonly zonelessEnabled;
71
85
  private readonly scheduler;
72
86
  private readonly rootEffectScheduler;
73
- private readonly microtaskEffectScheduler;
74
87
  private readonly autoDetectDefault;
75
88
  private autoDetect;
76
89
  private subscriptions;
@@ -121,48 +134,12 @@ export declare class ComponentFixture<T> {
121
134
  }
122
135
 
123
136
  /**
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.
137
+ * Clears out the shared fake async zone for a test.
138
+ * To be called in a global `beforeEach`.
161
139
  *
162
140
  * @publicApi
163
141
  */
164
- export declare function discardPeriodicTasks(): void;
165
-
142
+ declare function resetFakeAsyncZone(): void;
166
143
  /**
167
144
  * Wraps a function to be executed in the `fakeAsync` zone:
168
145
  * - Microtasks are manually executed by calling `flushMicrotasks()`.
@@ -187,46 +164,76 @@ export declare function discardPeriodicTasks(): void;
187
164
  *
188
165
  * @publicApi
189
166
  */
190
- export declare function fakeAsync(fn: Function, options?: {
167
+ declare function fakeAsync(fn: Function, options?: {
191
168
  flush?: boolean;
192
169
  }): (...args: any[]) => any;
193
-
194
170
  /**
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
- /**
222
- * Fake equivalent of the `NavigationResult` interface with
223
- * `FakeNavigationHistoryEntry`.
171
+ * Simulates the asynchronous passage of time for the timers in the `fakeAsync` zone.
172
+ *
173
+ * The microtasks queue is drained at the very start of this function and after any timer callback
174
+ * has been executed.
175
+ *
176
+ * @param millis The number of milliseconds to advance the virtual timer.
177
+ * @param tickOptions The options to pass to the `tick()` function.
178
+ *
179
+ * @usageNotes
180
+ *
181
+ * The `tick()` option is a flag called `processNewMacroTasksSynchronously`,
182
+ * which determines whether or not to invoke new macroTasks.
183
+ *
184
+ * If you provide a `tickOptions` object, but do not specify a
185
+ * `processNewMacroTasksSynchronously` property (`tick(100, {})`),
186
+ * then `processNewMacroTasksSynchronously` defaults to true.
187
+ *
188
+ * If you omit the `tickOptions` parameter (`tick(100))`), then
189
+ * `tickOptions` defaults to `{processNewMacroTasksSynchronously: true}`.
190
+ *
191
+ * ### Example
192
+ *
193
+ * {@example core/testing/ts/fake_async.ts region='basic'}
194
+ *
195
+ * The following example includes a nested timeout (new macroTask), and
196
+ * the `tickOptions` parameter is allowed to default. In this case,
197
+ * `processNewMacroTasksSynchronously` defaults to true, and the nested
198
+ * function is executed on each tick.
199
+ *
200
+ * ```ts
201
+ * it ('test with nested setTimeout', fakeAsync(() => {
202
+ * let nestedTimeoutInvoked = false;
203
+ * function funcWithNestedTimeout() {
204
+ * setTimeout(() => {
205
+ * nestedTimeoutInvoked = true;
206
+ * });
207
+ * };
208
+ * setTimeout(funcWithNestedTimeout);
209
+ * tick();
210
+ * expect(nestedTimeoutInvoked).toBe(true);
211
+ * }));
212
+ * ```
213
+ *
214
+ * In the following case, `processNewMacroTasksSynchronously` is explicitly
215
+ * set to false, so the nested timeout function is not invoked.
216
+ *
217
+ * ```ts
218
+ * it ('test with nested setTimeout', fakeAsync(() => {
219
+ * let nestedTimeoutInvoked = false;
220
+ * function funcWithNestedTimeout() {
221
+ * setTimeout(() => {
222
+ * nestedTimeoutInvoked = true;
223
+ * });
224
+ * };
225
+ * setTimeout(funcWithNestedTimeout);
226
+ * tick(0, {processNewMacroTasksSynchronously: false});
227
+ * expect(nestedTimeoutInvoked).toBe(false);
228
+ * }));
229
+ * ```
230
+ *
231
+ *
232
+ * @publicApi
224
233
  */
225
- declare interface FakeNavigationResult extends NavigationResult {
226
- readonly committed: Promise<FakeNavigationHistoryEntry>;
227
- readonly finished: Promise<FakeNavigationHistoryEntry>;
228
- }
229
-
234
+ declare function tick(millis?: number, tickOptions?: {
235
+ processNewMacroTasksSynchronously: boolean;
236
+ }): void;
230
237
  /**
231
238
  * Flushes any pending microtasks and simulates the asynchronous passage of time for the timers in
232
239
  * the `fakeAsync` zone by
@@ -238,222 +245,142 @@ declare interface FakeNavigationResult extends NavigationResult {
238
245
  *
239
246
  * @publicApi
240
247
  */
241
- export declare function flush(maxTurns?: number): number;
242
-
248
+ declare function flush(maxTurns?: number): number;
243
249
  /**
244
- * Flush any pending microtasks.
250
+ * Discard all remaining periodic tasks.
245
251
  *
246
252
  * @publicApi
247
253
  */
248
- export declare function flushMicrotasks(): void;
249
-
254
+ declare function discardPeriodicTasks(): void;
250
255
  /**
251
- * Returns a singleton of the `TestBed` class.
256
+ * Flush any pending microtasks.
252
257
  *
253
258
  * @publicApi
254
259
  */
255
- export declare function getTestBed(): TestBed;
260
+ declare function flushMicrotasks(): void;
256
261
 
257
262
  /**
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
- * ```
263
+ * Type used for modifications to metadata
276
264
  *
277
265
  * @publicApi
278
266
  */
279
- export declare function inject(tokens: any[], fn: Function): () => any;
267
+ type MetadataOverride<T> = {
268
+ add?: Partial<T>;
269
+ remove?: Partial<T>;
270
+ set?: Partial<T>;
271
+ };
280
272
 
281
273
  /**
274
+ * An abstract class for inserting the root test component element in a platform independent way.
275
+ *
282
276
  * @publicApi
283
277
  */
284
- export declare class InjectSetupWrapper {
285
- private _moduleDef;
286
- constructor(_moduleDef: () => TestModuleMetadata);
287
- private _addModule;
288
- inject(tokens: any[], fn: Function): () => any;
278
+ declare class TestComponentRenderer {
279
+ insertRootElement(rootElementId: string): void;
280
+ removeAllRootElements?(): void;
289
281
  }
290
-
291
-
292
282
  /**
293
- * Type used for modifications to metadata
294
- *
295
283
  * @publicApi
296
284
  */
297
- export declare type MetadataOverride<T> = {
298
- add?: Partial<T>;
299
- remove?: Partial<T>;
300
- set?: Partial<T>;
301
- };
302
-
285
+ declare const ComponentFixtureAutoDetect: InjectionToken<boolean>;
303
286
  /**
304
- * Configures the test module teardown behavior in `TestBed`.
305
287
  * @publicApi
306
288
  */
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;
289
+ declare const ComponentFixtureNoNgZone: InjectionToken<boolean>;
290
+ /**
291
+ * @publicApi
292
+ */
293
+ interface TestModuleMetadata {
294
+ providers?: any[];
295
+ declarations?: any[];
296
+ imports?: any[];
297
+ schemas?: Array<SchemaMetadata | any[]>;
298
+ teardown?: ModuleTeardownOptions;
299
+ /**
300
+ * Whether NG0304 runtime errors should be thrown when unknown elements are present in component's
301
+ * template. Defaults to `false`, where the error is simply logged. If set to `true`, the error is
302
+ * thrown.
303
+ * @see [NG8001](/errors/NG8001) for the description of the problem and how to fix it
304
+ */
305
+ errorOnUnknownElements?: boolean;
306
+ /**
307
+ * Whether errors should be thrown when unknown properties are present in component's template.
308
+ * Defaults to `false`, where the error is simply logged.
309
+ * If set to `true`, the error is thrown.
310
+ * @see [NG8002](/errors/NG8002) for the description of the error and how to fix it
311
+ */
312
+ errorOnUnknownProperties?: boolean;
313
+ /**
314
+ * Whether errors that happen during application change detection should be rethrown.
315
+ *
316
+ * When `true`, errors that are caught during application change detection will
317
+ * be reported to the `ErrorHandler` and rethrown to prevent them from going
318
+ * unnoticed in tests.
319
+ *
320
+ * When `false`, errors are only forwarded to the `ErrorHandler`, which by default
321
+ * simply logs them to the console.
322
+ *
323
+ * Defaults to `true`.
324
+ */
325
+ rethrowApplicationErrors?: boolean;
326
+ /**
327
+ * Whether defer blocks should behave with manual triggering or play through normally.
328
+ * Defaults to `manual`.
329
+ */
330
+ deferBlockBehavior?: _DeferBlockBehavior;
426
331
  }
427
-
428
- declare interface NavigationResult {
429
- committed: Promise<NavigationHistoryEntry>;
430
- finished: Promise<NavigationHistoryEntry>;
332
+ /**
333
+ * @publicApi
334
+ */
335
+ interface TestEnvironmentOptions {
336
+ /**
337
+ * Configures the test module teardown behavior in `TestBed`.
338
+ */
339
+ teardown?: ModuleTeardownOptions;
340
+ /**
341
+ * Whether errors should be thrown when unknown elements are present in component's template.
342
+ * Defaults to `false`, where the error is simply logged.
343
+ * If set to `true`, the error is thrown.
344
+ * @see [NG8001](/errors/NG8001) for the description of the error and how to fix it
345
+ */
346
+ errorOnUnknownElements?: boolean;
347
+ /**
348
+ * Whether errors should be thrown when unknown properties are present in component's template.
349
+ * Defaults to `false`, where the error is simply logged.
350
+ * If set to `true`, the error is thrown.
351
+ * @see [NG8002](/errors/NG8002) for the description of the error and how to fix it
352
+ */
353
+ errorOnUnknownProperties?: boolean;
431
354
  }
432
-
433
- declare class NavigationTransition {
434
- readonly navigationType: NavigationTypeString;
435
- readonly from: NavigationHistoryEntry;
436
- readonly finished: Promise<void>;
355
+ /**
356
+ * Configures the test module teardown behavior in `TestBed`.
357
+ * @publicApi
358
+ */
359
+ interface ModuleTeardownOptions {
360
+ /** Whether the test module should be destroyed after every test. Defaults to `true`. */
361
+ destroyAfterEach: boolean;
362
+ /** Whether errors during test module destruction should be re-thrown. Defaults to `true`. */
363
+ rethrowErrors?: boolean;
437
364
  }
438
365
 
439
- declare type NavigationTypeString = 'reload' | 'push' | 'replace' | 'traverse';
440
-
441
- declare interface NavigationUpdateCurrentEntryOptions {
442
- state: unknown;
366
+ /**
367
+ * Static methods implemented by the `TestBed`.
368
+ *
369
+ * @publicApi
370
+ */
371
+ interface TestBedStatic extends TestBed {
372
+ new (...args: any[]): TestBed;
443
373
  }
444
-
445
374
  /**
446
- * Clears out the shared fake async zone for a test.
447
- * To be called in a global `beforeEach`.
375
+ * Returns a singleton of the `TestBed` class.
448
376
  *
449
377
  * @publicApi
450
378
  */
451
- export declare function resetFakeAsyncZone(): void;
452
-
379
+ declare function getTestBed(): TestBed;
453
380
  /**
454
381
  * @publicApi
455
382
  */
456
- export declare interface TestBed {
383
+ interface TestBed {
457
384
  get platform(): PlatformRef;
458
385
  get ngModule(): Type<any> | Type<any>[];
459
386
  /**
@@ -484,12 +411,6 @@ export declare interface TestBed {
484
411
  }): T;
485
412
  inject<T>(token: ProviderToken<T>, notFoundValue: null | undefined, options: InjectOptions): T | null;
486
413
  inject<T>(token: ProviderToken<T>, notFoundValue?: T, options?: InjectOptions): T;
487
- /** @deprecated use object-based flags (`InjectOptions`) instead. */
488
- inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
489
- /** @deprecated use object-based flags (`InjectOptions`) instead. */
490
- inject<T>(token: ProviderToken<T>, notFoundValue: null, flags?: InjectFlags): T | null;
491
- /** @deprecated from v9.0.0 use TestBed.inject */
492
- get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): any;
493
414
  /** @deprecated from v9.0.0 use TestBed.inject */
494
415
  get(token: any, notFoundValue?: any): any;
495
416
  /**
@@ -531,7 +452,6 @@ export declare interface TestBed {
531
452
  */
532
453
  flushEffects(): void;
533
454
  }
534
-
535
455
  /**
536
456
  * @description
537
457
  * Configures and initializes environment for unit testing and provides methods for
@@ -541,195 +461,72 @@ export declare interface TestBed {
541
461
  *
542
462
  * @publicApi
543
463
  */
544
- export declare const TestBed: TestBedStatic;
545
-
464
+ declare const TestBed: TestBedStatic;
546
465
  /**
547
- * Static methods implemented by the `TestBed`.
466
+ * Allows injecting dependencies in `beforeEach()` and `it()`. Note: this function
467
+ * (imported from the `@angular/core/testing` package) can **only** be used to inject dependencies
468
+ * in tests. To inject dependencies in your application code, use the [`inject`](api/core/inject)
469
+ * function from the `@angular/core` package instead.
548
470
  *
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.
471
+ * Example:
472
+ *
473
+ * ```ts
474
+ * beforeEach(inject([Dependency, AClass], (dep, object) => {
475
+ * // some code that uses `dep` and `object`
476
+ * // ...
477
+ * }));
478
+ *
479
+ * it('...', inject([AClass], (object) => {
480
+ * object.doSomething();
481
+ * expect(...);
482
+ * })
483
+ * ```
557
484
  *
558
485
  * @publicApi
559
486
  */
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
-
487
+ declare function inject(tokens: any[], fn: Function): () => any;
589
488
  /**
590
489
  * @publicApi
591
490
  */
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;
491
+ declare class InjectSetupWrapper {
492
+ private _moduleDef;
493
+ constructor(_moduleDef: () => TestModuleMetadata);
494
+ private _addModule;
495
+ inject(tokens: any[], fn: Function): () => any;
630
496
  }
631
-
632
497
  /**
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
498
  * @publicApi
695
499
  */
696
- export declare function tick(millis?: number, tickOptions?: {
697
- processNewMacroTasksSynchronously: boolean;
698
- }): void;
699
-
500
+ declare function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper;
501
+ declare function withModule(moduleDef: TestModuleMetadata, fn: Function): () => any;
700
502
 
701
503
  /**
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:
504
+ * This API should be removed. But doing so seems to break `google3` and so it requires a bit of
505
+ * investigation.
707
506
  *
708
- * ```ts
709
- * it('...', waitForAsync(inject([AClass], (object) => {
710
- * object.doSomething.then(() => {
711
- * expect(...);
712
- * })
713
- * })));
714
- * ```
507
+ * A work around is to mark it as `@codeGenApi` for now and investigate later.
715
508
  *
716
- * @publicApi
717
- */
718
- export declare function waitForAsync(fn: Function): (done: any) => any;
719
-
720
- /**
721
- * @publicApi
509
+ * @codeGenApi
722
510
  */
723
- export declare function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper;
511
+ declare const __core_private_testing_placeholder__ = "";
724
512
 
725
- export declare function withModule(moduleDef: TestModuleMetadata, fn: Function): () => any;
513
+ declare class MetadataOverrider {
514
+ private _references;
515
+ /**
516
+ * Creates a new instance for the given metadata class
517
+ * based on an old instance and overrides.
518
+ */
519
+ overrideMetadata<C extends T, T>(metadataClass: {
520
+ new (options: T): C;
521
+ }, oldMetadata: C, override: MetadataOverride<T>): C;
522
+ }
726
523
 
727
524
  /**
728
525
  * Fake implementation of user agent history and navigation behavior. This is a
729
526
  * high-fidelity implementation of browser behavior that attempts to emulate
730
527
  * things like traversal delay.
731
528
  */
732
- export declare class ɵFakeNavigation implements Navigation {
529
+ declare class FakeNavigation implements Navigation {
733
530
  private readonly window;
734
531
  /**
735
532
  * The fake implementation of an entries array. Only same-document entries
@@ -740,10 +537,6 @@ export declare class ɵFakeNavigation implements Navigation {
740
537
  * The current active entry index into `entriesArr`.
741
538
  */
742
539
  private currentEntryIndex;
743
- /**
744
- * The current navigate event.
745
- */
746
- private navigateEvent;
747
540
  /**
748
541
  * A Map of pending traversals, so that traversals to the same entry can be
749
542
  * re-used.
@@ -766,8 +559,6 @@ export declare class ɵFakeNavigation implements Navigation {
766
559
  private synchronousTraversals;
767
560
  /** Whether to allow a call to setInitialEntryForTesting. */
768
561
  private canSetInitialEntry;
769
- /** `EventTarget` to dispatch events. */
770
- private eventTarget;
771
562
  /** The next unique id for created entries. Replace recreates this id. */
772
563
  private nextId;
773
564
  /** The next unique key for created entries. Replace inherits this id. */
@@ -830,12 +621,25 @@ export declare class ɵFakeNavigation implements Navigation {
830
621
  isDisposed(): boolean;
831
622
  /** Implementation for all navigations and traversals. */
832
623
  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. */
624
+ /**
625
+ * Implementation for a push or replace navigation.
626
+ * https://whatpr.org/html/10919/browsing-the-web.html#url-and-history-update-steps
627
+ * https://whatpr.org/html/10919/nav-history-apis.html#update-the-navigation-api-entries-for-a-same-document-navigation
628
+ */
629
+ private urlAndHistoryUpdateSteps;
630
+ /**
631
+ * Implementation for a traverse navigation.
632
+ *
633
+ * https://whatpr.org/html/10919/browsing-the-web.html#apply-the-traverse-history-step
634
+ * ...
635
+ * > 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.
636
+ * > If targetEntry's document is equal to displayedDocument, then perform updateDocument.
637
+ * https://whatpr.org/html/10919/browsing-the-web.html#update-document-for-history-step-application
638
+ * which then goes to https://whatpr.org/html/10919/nav-history-apis.html#update-the-navigation-api-entries-for-a-same-document-navigation
639
+ */
838
640
  private userAgentTraverse;
641
+ /** https://whatpr.org/html/10919/nav-history-apis.html#update-the-navigation-api-entries-for-a-same-document-navigation */
642
+ private updateNavigationEntriesForSameDocumentNavigation;
839
643
  /** Utility method for finding entries with the given `key`. */
840
644
  private findEntry;
841
645
  set onnavigate(_handler: ((this: Navigation, ev: NavigateEvent) => any) | null);
@@ -848,20 +652,47 @@ export declare class ɵFakeNavigation implements Navigation {
848
652
  get onnavigatesuccess(): ((this: Navigation, ev: Event) => any) | null;
849
653
  set onnavigateerror(_handler: ((this: Navigation, ev: ErrorEvent) => any) | null);
850
654
  get onnavigateerror(): ((this: Navigation, ev: ErrorEvent) => any) | null;
655
+ private _transition;
851
656
  get transition(): NavigationTransition | null;
852
657
  updateCurrentEntry(_options: NavigationUpdateCurrentEntryOptions): void;
853
658
  reload(_options?: NavigationReloadOptions): NavigationResult;
854
659
  }
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;
660
+ /**
661
+ * Fake equivalent of the `NavigationResult` interface with
662
+ * `FakeNavigationHistoryEntry`.
663
+ */
664
+ interface FakeNavigationResult extends NavigationResult {
665
+ readonly committed: Promise<FakeNavigationHistoryEntry>;
666
+ readonly finished: Promise<FakeNavigationHistoryEntry>;
667
+ }
668
+ /**
669
+ * Fake equivalent of `NavigationHistoryEntry`.
670
+ */
671
+ declare class FakeNavigationHistoryEntry implements NavigationHistoryEntry {
672
+ private eventTarget;
673
+ readonly url: string | null;
674
+ readonly sameDocument: boolean;
675
+ readonly id: string;
676
+ readonly key: string;
677
+ readonly index: number;
678
+ private readonly state;
679
+ private readonly historyState;
680
+ ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null;
681
+ constructor(eventTarget: EventTarget, url: string | null, { id, key, index, sameDocument, state, historyState, }: {
682
+ id: string;
683
+ key: string;
684
+ index: number;
685
+ sameDocument: boolean;
686
+ historyState: unknown;
687
+ state?: unknown;
688
+ });
689
+ getState(): unknown;
690
+ getHistoryState(): unknown;
691
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: AddEventListenerOptions | boolean): void;
692
+ removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: EventListenerOptions | boolean): void;
693
+ dispatchEvent(event: Event): boolean;
694
+ /** internal */
695
+ dispose(): void;
865
696
  }
866
697
 
867
- export { }
698
+ 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 };