@angular/core 20.0.0-next.1 → 20.0.0-next.3

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 (54) hide show
  1. package/fesm2022/core.mjs +770 -2144
  2. package/fesm2022/core.mjs.map +1 -1
  3. package/fesm2022/primitives/di.mjs +3 -2
  4. package/fesm2022/primitives/di.mjs.map +1 -1
  5. package/fesm2022/primitives/event-dispatch.mjs +2 -589
  6. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  7. package/fesm2022/primitives/signals.mjs +44 -13
  8. package/fesm2022/primitives/signals.mjs.map +1 -1
  9. package/fesm2022/rxjs-interop.mjs +7 -39
  10. package/fesm2022/rxjs-interop.mjs.map +1 -1
  11. package/fesm2022/testing.mjs +116 -143
  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 +14366 -15214
  16. package/navigation_types.d-u4EOrrdZ.d.ts +121 -0
  17. package/package.json +2 -2
  18. package/primitives/di/index.d.ts +66 -59
  19. package/primitives/event-dispatch/index.d.ts +205 -309
  20. package/primitives/signals/index.d.ts +161 -195
  21. package/rxjs-interop/index.d.ts +71 -100
  22. package/schematics/bundles/{apply_import_manager-e2a7fe5b.js → apply_import_manager-BXQEjo09.js} +15 -19
  23. package/schematics/bundles/{checker-af521da6.js → checker-BHb19MHt.js} +3695 -1175
  24. package/schematics/bundles/cleanup-unused-imports.js +56 -89
  25. package/schematics/bundles/{compiler_host-5a29293c.js → compiler_host-Bk3repE2.js} +19 -23
  26. package/schematics/bundles/control-flow-migration.js +81 -38
  27. package/schematics/bundles/{imports-047fbbc8.js → imports-CIX-JgAN.js} +9 -14
  28. package/schematics/bundles/{index-1bef3025.js → index-BL9kAIe5.js} +62 -66
  29. package/schematics/bundles/{program-a449f9bf.js → index-I8VbxQcO.js} +1508 -3178
  30. package/schematics/bundles/inject-flags.js +147 -0
  31. package/schematics/bundles/inject-migration.js +121 -127
  32. package/schematics/bundles/{leading_space-f8944434.js → leading_space-D9nQ8UQC.js} +1 -1
  33. package/schematics/bundles/{migrate_ts_type_references-2a3e9e6b.js → migrate_ts_type_references-KlOTWeDl.js} +121 -126
  34. package/schematics/bundles/{ng_decorators-b0d8b324.js → ng_decorators-DznZ5jMl.js} +4 -8
  35. package/schematics/bundles/{nodes-7758dbf6.js → nodes-B16H9JUd.js} +2 -6
  36. package/schematics/bundles/output-migration.js +94 -128
  37. package/schematics/bundles/{project_tsconfig_paths-b558633b.js → project_tsconfig_paths-CDVxT6Ov.js} +1 -1
  38. package/schematics/bundles/{property_name-ac18447e.js → property_name-BBwFuqMe.js} +3 -7
  39. package/schematics/bundles/route-lazy-loading.js +35 -41
  40. package/schematics/bundles/{project_paths-17dc204d.js → run_in_devkit-C0JPtK2u.js} +283 -216
  41. package/schematics/bundles/self-closing-tags-migration.js +55 -91
  42. package/schematics/bundles/signal-input-migration.js +121 -156
  43. package/schematics/bundles/signal-queries-migration.js +119 -154
  44. package/schematics/bundles/signals.js +12 -14
  45. package/schematics/bundles/standalone-migration.js +180 -200
  46. package/schematics/bundles/symbol-VPWguRxr.js +25 -0
  47. package/schematics/bundles/test-bed-get.js +98 -0
  48. package/schematics/migrations.json +8 -14
  49. package/testing/index.d.ts +289 -471
  50. package/weak_ref.d-ttyj86RV.d.ts +9 -0
  51. package/schematics/bundles/explicit-standalone-flag.js +0 -184
  52. package/schematics/bundles/index-ef1bffbb.js +0 -30
  53. package/schematics/bundles/pending-tasks.js +0 -103
  54. package/schematics/bundles/provide-initializer.js +0 -186
@@ -1,46 +1,60 @@
1
1
  /**
2
- * @license Angular v20.0.0-next.1
2
+ * @license Angular v20.0.0-next.3
3
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
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.
@@ -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,49 +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
- private eventTarget;
199
- readonly url: string | null;
200
- readonly sameDocument: boolean;
201
- readonly id: string;
202
- readonly key: string;
203
- readonly index: number;
204
- private readonly state;
205
- private readonly historyState;
206
- ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null;
207
- constructor(eventTarget: EventTarget, url: string | null, { id, key, index, sameDocument, state, historyState, }: {
208
- id: string;
209
- key: string;
210
- index: number;
211
- sameDocument: boolean;
212
- historyState: unknown;
213
- state?: unknown;
214
- });
215
- getState(): unknown;
216
- getHistoryState(): unknown;
217
- addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: AddEventListenerOptions | boolean): void;
218
- removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: EventListenerOptions | boolean): void;
219
- dispatchEvent(event: Event): boolean;
220
- /** internal */
221
- dispose(): void;
222
- }
223
-
224
- /**
225
- * Fake equivalent of the `NavigationResult` interface with
226
- * `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
227
233
  */
228
- declare interface FakeNavigationResult extends NavigationResult {
229
- readonly committed: Promise<FakeNavigationHistoryEntry>;
230
- readonly finished: Promise<FakeNavigationHistoryEntry>;
231
- }
232
-
234
+ declare function tick(millis?: number, tickOptions?: {
235
+ processNewMacroTasksSynchronously: boolean;
236
+ }): void;
233
237
  /**
234
238
  * Flushes any pending microtasks and simulates the asynchronous passage of time for the timers in
235
239
  * the `fakeAsync` zone by
@@ -241,222 +245,142 @@ declare interface FakeNavigationResult extends NavigationResult {
241
245
  *
242
246
  * @publicApi
243
247
  */
244
- export declare function flush(maxTurns?: number): number;
245
-
248
+ declare function flush(maxTurns?: number): number;
246
249
  /**
247
- * Flush any pending microtasks.
250
+ * Discard all remaining periodic tasks.
248
251
  *
249
252
  * @publicApi
250
253
  */
251
- export declare function flushMicrotasks(): void;
252
-
254
+ declare function discardPeriodicTasks(): void;
253
255
  /**
254
- * Returns a singleton of the `TestBed` class.
256
+ * Flush any pending microtasks.
255
257
  *
256
258
  * @publicApi
257
259
  */
258
- export declare function getTestBed(): TestBed;
260
+ declare function flushMicrotasks(): void;
259
261
 
260
262
  /**
261
- * Allows injecting dependencies in `beforeEach()` and `it()`. Note: this function
262
- * (imported from the `@angular/core/testing` package) can **only** be used to inject dependencies
263
- * in tests. To inject dependencies in your application code, use the [`inject`](api/core/inject)
264
- * function from the `@angular/core` package instead.
265
- *
266
- * Example:
267
- *
268
- * ```ts
269
- * beforeEach(inject([Dependency, AClass], (dep, object) => {
270
- * // some code that uses `dep` and `object`
271
- * // ...
272
- * }));
273
- *
274
- * it('...', inject([AClass], (object) => {
275
- * object.doSomething();
276
- * expect(...);
277
- * })
278
- * ```
263
+ * Type used for modifications to metadata
279
264
  *
280
265
  * @publicApi
281
266
  */
282
- 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
+ };
283
272
 
284
273
  /**
274
+ * An abstract class for inserting the root test component element in a platform independent way.
275
+ *
285
276
  * @publicApi
286
277
  */
287
- export declare class InjectSetupWrapper {
288
- private _moduleDef;
289
- constructor(_moduleDef: () => TestModuleMetadata);
290
- private _addModule;
291
- inject(tokens: any[], fn: Function): () => any;
278
+ declare class TestComponentRenderer {
279
+ insertRootElement(rootElementId: string): void;
280
+ removeAllRootElements?(): void;
292
281
  }
293
-
294
-
295
282
  /**
296
- * Type used for modifications to metadata
297
- *
298
283
  * @publicApi
299
284
  */
300
- export declare type MetadataOverride<T> = {
301
- add?: Partial<T>;
302
- remove?: Partial<T>;
303
- set?: Partial<T>;
304
- };
305
-
285
+ declare const ComponentFixtureAutoDetect: InjectionToken<boolean>;
306
286
  /**
307
- * Configures the test module teardown behavior in `TestBed`.
308
287
  * @publicApi
309
288
  */
310
- export declare interface ModuleTeardownOptions {
311
- /** Whether the test module should be destroyed after every test. Defaults to `true`. */
312
- destroyAfterEach: boolean;
313
- /** Whether errors during test module destruction should be re-thrown. Defaults to `true`. */
314
- rethrowErrors?: boolean;
315
- }
316
-
317
- declare class NavigateEvent extends Event {
318
- constructor(type: string, eventInit?: NavigateEventInit);
319
- readonly navigationType: NavigationTypeString;
320
- readonly canIntercept: boolean;
321
- readonly userInitiated: boolean;
322
- readonly hashChange: boolean;
323
- readonly destination: NavigationDestination;
324
- readonly signal: AbortSignal;
325
- readonly formData: FormData | null;
326
- readonly downloadRequest: string | null;
327
- readonly info?: unknown;
328
- intercept(options?: NavigationInterceptOptions): void;
329
- scroll(): void;
330
- }
331
-
332
- declare interface NavigateEventInit extends EventInit {
333
- navigationType?: NavigationTypeString;
334
- canIntercept?: boolean;
335
- userInitiated?: boolean;
336
- hashChange?: boolean;
337
- destination: NavigationDestination;
338
- signal: AbortSignal;
339
- formData?: FormData | null;
340
- downloadRequest?: string | null;
341
- info?: unknown;
342
- }
343
-
344
- declare class Navigation extends EventTarget {
345
- entries(): NavigationHistoryEntry[];
346
- readonly currentEntry: NavigationHistoryEntry | null;
347
- updateCurrentEntry(options: NavigationUpdateCurrentEntryOptions): void;
348
- readonly transition: NavigationTransition | null;
349
- readonly canGoBack: boolean;
350
- readonly canGoForward: boolean;
351
- navigate(url: string, options?: NavigationNavigateOptions): NavigationResult;
352
- reload(options?: NavigationReloadOptions): NavigationResult;
353
- traverseTo(key: string, options?: NavigationOptions): NavigationResult;
354
- back(options?: NavigationOptions): NavigationResult;
355
- forward(options?: NavigationOptions): NavigationResult;
356
- onnavigate: ((this: Navigation, ev: NavigateEvent) => any) | null;
357
- onnavigatesuccess: ((this: Navigation, ev: Event) => any) | null;
358
- onnavigateerror: ((this: Navigation, ev: ErrorEvent) => any) | null;
359
- oncurrententrychange: ((this: Navigation, ev: NavigationCurrentEntryChangeEvent) => any) | null;
360
- addEventListener<K extends keyof NavigationEventMap>(type: K, listener: (this: Navigation, ev: NavigationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
361
- addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
362
- removeEventListener<K extends keyof NavigationEventMap>(type: K, listener: (this: Navigation, ev: NavigationEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
363
- removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
364
- }
365
-
366
- declare class NavigationCurrentEntryChangeEvent extends Event {
367
- constructor(type: string, eventInit?: NavigationCurrentEntryChangeEventInit);
368
- readonly navigationType: NavigationTypeString | null;
369
- readonly from: NavigationHistoryEntry;
370
- }
371
-
372
- declare interface NavigationCurrentEntryChangeEventInit extends EventInit {
373
- navigationType?: NavigationTypeString | null;
374
- from: NavigationHistoryEntry;
375
- }
376
-
377
- declare class NavigationDestination {
378
- readonly url: string;
379
- readonly key: string | null;
380
- readonly id: string | null;
381
- readonly index: number;
382
- readonly sameDocument: boolean;
383
- getState(): unknown;
384
- }
385
-
386
-
387
- declare interface NavigationEventMap {
388
- navigate: NavigateEvent;
389
- navigatesuccess: Event;
390
- navigateerror: ErrorEvent;
391
- currententrychange: NavigationCurrentEntryChangeEvent;
392
- }
393
-
394
- declare class NavigationHistoryEntry extends EventTarget {
395
- readonly key: string;
396
- readonly id: string;
397
- readonly url: string | null;
398
- readonly index: number;
399
- readonly sameDocument: boolean;
400
- getState(): unknown;
401
- ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null;
402
- addEventListener<K extends keyof NavigationHistoryEntryEventMap>(type: K, listener: (this: NavigationHistoryEntry, ev: NavigationHistoryEntryEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
403
- addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
404
- removeEventListener<K extends keyof NavigationHistoryEntryEventMap>(type: K, listener: (this: NavigationHistoryEntry, ev: NavigationHistoryEntryEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
405
- removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
406
- }
407
-
408
- declare interface NavigationHistoryEntryEventMap {
409
- dispose: Event;
410
- }
411
-
412
- declare interface NavigationInterceptOptions {
413
- handler?: () => Promise<void>;
414
- focusReset?: 'after-transition' | 'manual';
415
- scroll?: 'after-transition' | 'manual';
416
- }
417
-
418
- declare interface NavigationNavigateOptions extends NavigationOptions {
419
- state?: unknown;
420
- history?: 'auto' | 'push' | 'replace';
421
- }
422
-
423
- declare interface NavigationOptions {
424
- info?: unknown;
425
- }
426
-
427
- declare interface NavigationReloadOptions extends NavigationOptions {
428
- 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;
429
331
  }
430
-
431
- declare interface NavigationResult {
432
- committed: Promise<NavigationHistoryEntry>;
433
- 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;
434
354
  }
435
-
436
- declare class NavigationTransition {
437
- readonly navigationType: NavigationTypeString;
438
- readonly from: NavigationHistoryEntry;
439
- 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;
440
364
  }
441
365
 
442
- declare type NavigationTypeString = 'reload' | 'push' | 'replace' | 'traverse';
443
-
444
- declare interface NavigationUpdateCurrentEntryOptions {
445
- state: unknown;
366
+ /**
367
+ * Static methods implemented by the `TestBed`.
368
+ *
369
+ * @publicApi
370
+ */
371
+ interface TestBedStatic extends TestBed {
372
+ new (...args: any[]): TestBed;
446
373
  }
447
-
448
374
  /**
449
- * Clears out the shared fake async zone for a test.
450
- * To be called in a global `beforeEach`.
375
+ * Returns a singleton of the `TestBed` class.
451
376
  *
452
377
  * @publicApi
453
378
  */
454
- export declare function resetFakeAsyncZone(): void;
455
-
379
+ declare function getTestBed(): TestBed;
456
380
  /**
457
381
  * @publicApi
458
382
  */
459
- export declare interface TestBed {
383
+ interface TestBed {
460
384
  get platform(): PlatformRef;
461
385
  get ngModule(): Type<any> | Type<any>[];
462
386
  /**
@@ -487,14 +411,6 @@ export declare interface TestBed {
487
411
  }): T;
488
412
  inject<T>(token: ProviderToken<T>, notFoundValue: null | undefined, options: InjectOptions): T | null;
489
413
  inject<T>(token: ProviderToken<T>, notFoundValue?: T, options?: InjectOptions): T;
490
- /** @deprecated use object-based flags (`InjectOptions`) instead. */
491
- inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
492
- /** @deprecated use object-based flags (`InjectOptions`) instead. */
493
- inject<T>(token: ProviderToken<T>, notFoundValue: null, flags?: InjectFlags): T | null;
494
- /** @deprecated from v9.0.0 use TestBed.inject */
495
- get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): any;
496
- /** @deprecated from v9.0.0 use TestBed.inject */
497
- get(token: any, notFoundValue?: any): any;
498
414
  /**
499
415
  * Runs the given function in the `EnvironmentInjector` context of `TestBed`.
500
416
  *
@@ -534,7 +450,6 @@ export declare interface TestBed {
534
450
  */
535
451
  flushEffects(): void;
536
452
  }
537
-
538
453
  /**
539
454
  * @description
540
455
  * Configures and initializes environment for unit testing and provides methods for
@@ -544,195 +459,72 @@ export declare interface TestBed {
544
459
  *
545
460
  * @publicApi
546
461
  */
547
- export declare const TestBed: TestBedStatic;
548
-
462
+ declare const TestBed: TestBedStatic;
549
463
  /**
550
- * Static methods implemented by the `TestBed`.
464
+ * Allows injecting dependencies in `beforeEach()` and `it()`. Note: this function
465
+ * (imported from the `@angular/core/testing` package) can **only** be used to inject dependencies
466
+ * in tests. To inject dependencies in your application code, use the [`inject`](api/core/inject)
467
+ * function from the `@angular/core` package instead.
551
468
  *
552
- * @publicApi
553
- */
554
- export declare interface TestBedStatic extends TestBed {
555
- new (...args: any[]): TestBed;
556
- }
557
-
558
- /**
559
- * An abstract class for inserting the root test component element in a platform independent way.
469
+ * Example:
470
+ *
471
+ * ```ts
472
+ * beforeEach(inject([Dependency, AClass], (dep, object) => {
473
+ * // some code that uses `dep` and `object`
474
+ * // ...
475
+ * }));
476
+ *
477
+ * it('...', inject([AClass], (object) => {
478
+ * object.doSomething();
479
+ * expect(...);
480
+ * })
481
+ * ```
560
482
  *
561
483
  * @publicApi
562
484
  */
563
- export declare class TestComponentRenderer {
564
- insertRootElement(rootElementId: string): void;
565
- removeAllRootElements?(): void;
566
- }
567
-
568
- /**
569
- * @publicApi
570
- */
571
- export declare interface TestEnvironmentOptions {
572
- /**
573
- * Configures the test module teardown behavior in `TestBed`.
574
- */
575
- teardown?: ModuleTeardownOptions;
576
- /**
577
- * Whether errors should be thrown when unknown elements are present in component's template.
578
- * Defaults to `false`, where the error is simply logged.
579
- * If set to `true`, the error is thrown.
580
- * @see [NG8001](/errors/NG8001) for the description of the error and how to fix it
581
- */
582
- errorOnUnknownElements?: boolean;
583
- /**
584
- * Whether errors should be thrown when unknown properties are present in component's template.
585
- * Defaults to `false`, where the error is simply logged.
586
- * If set to `true`, the error is thrown.
587
- * @see [NG8002](/errors/NG8002) for the description of the error and how to fix it
588
- */
589
- errorOnUnknownProperties?: boolean;
590
- }
591
-
485
+ declare function inject(tokens: any[], fn: Function): () => any;
592
486
  /**
593
487
  * @publicApi
594
488
  */
595
- export declare interface TestModuleMetadata {
596
- providers?: any[];
597
- declarations?: any[];
598
- imports?: any[];
599
- schemas?: Array<SchemaMetadata | any[]>;
600
- teardown?: ModuleTeardownOptions;
601
- /**
602
- * Whether NG0304 runtime errors should be thrown when unknown elements are present in component's
603
- * template. Defaults to `false`, where the error is simply logged. If set to `true`, the error is
604
- * thrown.
605
- * @see [NG8001](/errors/NG8001) for the description of the problem and how to fix it
606
- */
607
- errorOnUnknownElements?: boolean;
608
- /**
609
- * Whether errors should be thrown when unknown properties are present in component's template.
610
- * Defaults to `false`, where the error is simply logged.
611
- * If set to `true`, the error is thrown.
612
- * @see [NG8002](/errors/NG8002) for the description of the error and how to fix it
613
- */
614
- errorOnUnknownProperties?: boolean;
615
- /**
616
- * Whether errors that happen during application change detection should be rethrown.
617
- *
618
- * When `true`, errors that are caught during application change detection will
619
- * be reported to the `ErrorHandler` and rethrown to prevent them from going
620
- * unnoticed in tests.
621
- *
622
- * When `false`, errors are only forwarded to the `ErrorHandler`, which by default
623
- * simply logs them to the console.
624
- *
625
- * Defaults to `true`.
626
- */
627
- rethrowApplicationErrors?: boolean;
628
- /**
629
- * Whether defer blocks should behave with manual triggering or play through normally.
630
- * Defaults to `manual`.
631
- */
632
- deferBlockBehavior?: DeferBlockBehavior;
489
+ declare class InjectSetupWrapper {
490
+ private _moduleDef;
491
+ constructor(_moduleDef: () => TestModuleMetadata);
492
+ private _addModule;
493
+ inject(tokens: any[], fn: Function): () => any;
633
494
  }
634
-
635
495
  /**
636
- * Simulates the asynchronous passage of time for the timers in the `fakeAsync` zone.
637
- *
638
- * The microtasks queue is drained at the very start of this function and after any timer callback
639
- * has been executed.
640
- *
641
- * @param millis The number of milliseconds to advance the virtual timer.
642
- * @param tickOptions The options to pass to the `tick()` function.
643
- *
644
- * @usageNotes
645
- *
646
- * The `tick()` option is a flag called `processNewMacroTasksSynchronously`,
647
- * which determines whether or not to invoke new macroTasks.
648
- *
649
- * If you provide a `tickOptions` object, but do not specify a
650
- * `processNewMacroTasksSynchronously` property (`tick(100, {})`),
651
- * then `processNewMacroTasksSynchronously` defaults to true.
652
- *
653
- * If you omit the `tickOptions` parameter (`tick(100))`), then
654
- * `tickOptions` defaults to `{processNewMacroTasksSynchronously: true}`.
655
- *
656
- * ### Example
657
- *
658
- * {@example core/testing/ts/fake_async.ts region='basic'}
659
- *
660
- * The following example includes a nested timeout (new macroTask), and
661
- * the `tickOptions` parameter is allowed to default. In this case,
662
- * `processNewMacroTasksSynchronously` defaults to true, and the nested
663
- * function is executed on each tick.
664
- *
665
- * ```ts
666
- * it ('test with nested setTimeout', fakeAsync(() => {
667
- * let nestedTimeoutInvoked = false;
668
- * function funcWithNestedTimeout() {
669
- * setTimeout(() => {
670
- * nestedTimeoutInvoked = true;
671
- * });
672
- * };
673
- * setTimeout(funcWithNestedTimeout);
674
- * tick();
675
- * expect(nestedTimeoutInvoked).toBe(true);
676
- * }));
677
- * ```
678
- *
679
- * In the following case, `processNewMacroTasksSynchronously` is explicitly
680
- * set to false, so the nested timeout function is not invoked.
681
- *
682
- * ```ts
683
- * it ('test with nested setTimeout', fakeAsync(() => {
684
- * let nestedTimeoutInvoked = false;
685
- * function funcWithNestedTimeout() {
686
- * setTimeout(() => {
687
- * nestedTimeoutInvoked = true;
688
- * });
689
- * };
690
- * setTimeout(funcWithNestedTimeout);
691
- * tick(0, {processNewMacroTasksSynchronously: false});
692
- * expect(nestedTimeoutInvoked).toBe(false);
693
- * }));
694
- * ```
695
- *
696
- *
697
496
  * @publicApi
698
497
  */
699
- export declare function tick(millis?: number, tickOptions?: {
700
- processNewMacroTasksSynchronously: boolean;
701
- }): void;
702
-
498
+ declare function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper;
499
+ declare function withModule(moduleDef: TestModuleMetadata, fn: Function): () => any;
703
500
 
704
501
  /**
705
- * Wraps a test function in an asynchronous test zone. The test will automatically
706
- * complete when all asynchronous calls within this zone are done. Can be used
707
- * to wrap an {@link inject} call.
708
- *
709
- * Example:
502
+ * This API should be removed. But doing so seems to break `google3` and so it requires a bit of
503
+ * investigation.
710
504
  *
711
- * ```ts
712
- * it('...', waitForAsync(inject([AClass], (object) => {
713
- * object.doSomething.then(() => {
714
- * expect(...);
715
- * })
716
- * })));
717
- * ```
505
+ * A work around is to mark it as `@codeGenApi` for now and investigate later.
718
506
  *
719
- * @publicApi
720
- */
721
- export declare function waitForAsync(fn: Function): (done: any) => any;
722
-
723
- /**
724
- * @publicApi
507
+ * @codeGenApi
725
508
  */
726
- export declare function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper;
509
+ declare const __core_private_testing_placeholder__ = "";
727
510
 
728
- export declare function withModule(moduleDef: TestModuleMetadata, fn: Function): () => any;
511
+ declare class MetadataOverrider {
512
+ private _references;
513
+ /**
514
+ * Creates a new instance for the given metadata class
515
+ * based on an old instance and overrides.
516
+ */
517
+ overrideMetadata<C extends T, T>(metadataClass: {
518
+ new (options: T): C;
519
+ }, oldMetadata: C, override: MetadataOverride<T>): C;
520
+ }
729
521
 
730
522
  /**
731
523
  * Fake implementation of user agent history and navigation behavior. This is a
732
524
  * high-fidelity implementation of browser behavior that attempts to emulate
733
525
  * things like traversal delay.
734
526
  */
735
- export declare class ɵFakeNavigation implements Navigation {
527
+ declare class FakeNavigation implements Navigation {
736
528
  private readonly window;
737
529
  /**
738
530
  * The fake implementation of an entries array. Only same-document entries
@@ -863,16 +655,42 @@ export declare class ɵFakeNavigation implements Navigation {
863
655
  updateCurrentEntry(_options: NavigationUpdateCurrentEntryOptions): void;
864
656
  reload(_options?: NavigationReloadOptions): NavigationResult;
865
657
  }
866
-
867
- export declare class ɵMetadataOverrider {
868
- private _references;
869
- /**
870
- * Creates a new instance for the given metadata class
871
- * based on an old instance and overrides.
872
- */
873
- overrideMetadata<C extends T, T>(metadataClass: {
874
- new (options: T): C;
875
- }, oldMetadata: C, override: MetadataOverride<T>): C;
658
+ /**
659
+ * Fake equivalent of the `NavigationResult` interface with
660
+ * `FakeNavigationHistoryEntry`.
661
+ */
662
+ interface FakeNavigationResult extends NavigationResult {
663
+ readonly committed: Promise<FakeNavigationHistoryEntry>;
664
+ readonly finished: Promise<FakeNavigationHistoryEntry>;
665
+ }
666
+ /**
667
+ * Fake equivalent of `NavigationHistoryEntry`.
668
+ */
669
+ declare class FakeNavigationHistoryEntry implements NavigationHistoryEntry {
670
+ private eventTarget;
671
+ readonly url: string | null;
672
+ readonly sameDocument: boolean;
673
+ readonly id: string;
674
+ readonly key: string;
675
+ readonly index: number;
676
+ private readonly state;
677
+ private readonly historyState;
678
+ ondispose: ((this: NavigationHistoryEntry, ev: Event) => any) | null;
679
+ constructor(eventTarget: EventTarget, url: string | null, { id, key, index, sameDocument, state, historyState, }: {
680
+ id: string;
681
+ key: string;
682
+ index: number;
683
+ sameDocument: boolean;
684
+ historyState: unknown;
685
+ state?: unknown;
686
+ });
687
+ getState(): unknown;
688
+ getHistoryState(): unknown;
689
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: AddEventListenerOptions | boolean): void;
690
+ removeEventListener(type: string, callback: EventListenerOrEventListenerObject, options?: EventListenerOptions | boolean): void;
691
+ dispatchEvent(event: Event): boolean;
692
+ /** internal */
693
+ dispose(): void;
876
694
  }
877
695
 
878
- export { }
696
+ 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 };