@angular/core 14.0.0-rc.1 → 14.0.0

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.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.0.0-rc.1
2
+ * @license Angular v14.0.0
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1026,6 +1026,11 @@ export declare interface Component extends Directive {
1026
1026
  * Angular components marked as `standalone` do not need to be declared in an NgModule. Such
1027
1027
  * components directly manage their own template dependencies (components, directives and pipes
1028
1028
  * used in a template) via the imports property.
1029
+ *
1030
+ * More information about standalone components, directives and pipes can be found in [this
1031
+ * guide](guide/standalone-components).
1032
+ *
1033
+ * @developerPreview
1029
1034
  */
1030
1035
  standalone?: boolean;
1031
1036
  /**
@@ -1035,6 +1040,11 @@ export declare interface Component extends Directive {
1035
1040
  *
1036
1041
  * This property is only available for standalone components - specifying it for components
1037
1042
  * declared in an NgModule generates a compilation error.
1043
+ *
1044
+ * More information about standalone components, directives and pipes can be found in [this
1045
+ * guide](guide/standalone-components).
1046
+ *
1047
+ * @developerPreview
1038
1048
  */
1039
1049
  imports?: (Type<any> | any[])[];
1040
1050
  /**
@@ -1043,6 +1053,9 @@ export declare interface Component extends Directive {
1043
1053
  *
1044
1054
  * This property is only available for standalone components - specifying it for components
1045
1055
  * declared in an NgModule generates a compilation error.
1056
+ *
1057
+ * More information about standalone components, directives and pipes can be found in [this
1058
+ * guide](guide/standalone-components).
1046
1059
  */
1047
1060
  schemas?: SchemaMetadata[];
1048
1061
  }
@@ -1634,6 +1647,7 @@ declare interface CreateComponentOptions {
1634
1647
  * Create a new environment injector.
1635
1648
  *
1636
1649
  * @publicApi
1650
+ * @developerPreview
1637
1651
  */
1638
1652
  export declare function createEnvironmentInjector(providers: Array<Provider | ImportedNgModuleProviders>, parent?: EnvironmentInjector | null, debugName?: string | null): EnvironmentInjector;
1639
1653
 
@@ -2271,6 +2285,11 @@ export declare interface Directive {
2271
2285
  * Angular directives marked as `standalone` do not need to be declared in an NgModule. Such
2272
2286
  * directives don't depend on any "intermediate context" of an NgModule (ex. configured
2273
2287
  * providers).
2288
+ *
2289
+ * More information about standalone components, directives and pipes can be found in [this
2290
+ * guide](guide/standalone-components).
2291
+ *
2292
+ * @developerPreview
2274
2293
  */
2275
2294
  standalone?: boolean;
2276
2295
  }
@@ -2315,21 +2334,53 @@ export declare interface DirectiveDecorator {
2315
2334
  *
2316
2335
  * ### Declaring directives
2317
2336
  *
2318
- * Directives are [declarables](guide/glossary#declarable).
2319
- * They must be declared by an NgModule
2320
- * in order to be usable in an app.
2337
+ * In order to make a directive available to other components in your application, you should do
2338
+ * one of the following:
2339
+ * - either mark the directive as [standalone](guide/standalone-components),
2340
+ * - or declare it in an NgModule by adding it to the `declarations` and `exports` fields.
2321
2341
  *
2322
- * A directive must belong to exactly one NgModule. Do not re-declare
2323
- * a directive imported from another module.
2324
- * List the directive class in the `declarations` field of an NgModule.
2342
+ * ** Marking a directive as standalone **
2343
+ *
2344
+ * You can add the `standalone: true` flag to the Directive decorator metadata to declare it as
2345
+ * [standalone](guide/standalone-components):
2325
2346
  *
2326
2347
  * ```ts
2327
- * declarations: [
2328
- * AppComponent,
2329
- * MyDirective
2330
- * ],
2348
+ * @Directive({
2349
+ * standalone: true,
2350
+ * selector: 'my-directive',
2351
+ * })
2352
+ * class MyDirective {}
2331
2353
  * ```
2332
2354
  *
2355
+ * When marking a directive as standalone, please make sure that the directive is not already
2356
+ * declared in an NgModule.
2357
+ *
2358
+ *
2359
+ * ** Declaring a directive in an NgModule **
2360
+ *
2361
+ * Another approach is to declare a directive in an NgModule:
2362
+ *
2363
+ * ```ts
2364
+ * @Directive({
2365
+ * selector: 'my-directive',
2366
+ * })
2367
+ * class MyDirective {}
2368
+ *
2369
+ * @NgModule({
2370
+ * declarations: [MyDirective, SomeComponent],
2371
+ * exports: [MyDirective], // making it available outside of this module
2372
+ * })
2373
+ * class SomeNgModule {}
2374
+ * ```
2375
+ *
2376
+ * When declaring a directive in an NgModule, please make sure that:
2377
+ * - the directive is declared in exactly one NgModule.
2378
+ * - the directive is not standalone.
2379
+ * - you do not re-declare a directive imported from another module.
2380
+ * - the directive is included into the `exports` field as well if you want this directive to be
2381
+ * accessible for components outside of the NgModule.
2382
+ *
2383
+ *
2333
2384
  * @Annotation
2334
2385
  */
2335
2386
  (obj?: Directive): TypeDecorator;
@@ -2566,6 +2617,8 @@ export declare const ENVIRONMENT_INITIALIZER: InjectionToken<() => void>;
2566
2617
  /**
2567
2618
  * An `Injector` that's part of the environment injector hierarchy, which exists outside of the
2568
2619
  * component tree.
2620
+ *
2621
+ * @developerPreview
2569
2622
  */
2570
2623
  export declare abstract class EnvironmentInjector implements Injector {
2571
2624
  /**
@@ -3428,6 +3481,7 @@ declare const ID = 20;
3428
3481
  * @see `importProvidersFrom`
3429
3482
  *
3430
3483
  * @publicApi
3484
+ * @developerPreview
3431
3485
  */
3432
3486
  export declare interface ImportedNgModuleProviders {
3433
3487
  ɵproviders: Provider[];
@@ -3441,8 +3495,38 @@ export declare interface ImportedNgModuleProviders {
3441
3495
  * another environment injector (such as a route injector). They should not be used in component
3442
3496
  * providers.
3443
3497
  *
3444
- * @returns The collected providers from the specified list of types.
3498
+ * More information about standalone components can be found in [this
3499
+ * guide](guide/standalone-components).
3500
+ *
3501
+ * @usageNotes
3502
+ * The results of the `importProvidersFrom` call can be used in the `bootstrapApplication` call:
3503
+ *
3504
+ * ```typescript
3505
+ * await bootstrapApplication(RootComponent, {
3506
+ * providers: [
3507
+ * importProvidersFrom(NgModuleOne, NgModuleTwo)
3508
+ * ]
3509
+ * });
3510
+ * ```
3511
+ *
3512
+ * You can also use the `importProvidersFrom` results in the `providers` field of a route, when a
3513
+ * standalone component is used:
3514
+ *
3515
+ * ```typescript
3516
+ * export const ROUTES: Route[] = [
3517
+ * {
3518
+ * path: 'foo',
3519
+ * providers: [
3520
+ * importProvidersFrom(NgModuleOne, NgModuleTwo)
3521
+ * ],
3522
+ * component: YourStandaloneComponent
3523
+ * }
3524
+ * ];
3525
+ * ```
3526
+ *
3527
+ * @returns Collected providers from the specified list of types.
3445
3528
  * @publicApi
3529
+ * @developerPreview
3446
3530
  */
3447
3531
  export declare function importProvidersFrom(...sources: ImportProvidersSource[]): ImportedNgModuleProviders;
3448
3532
 
@@ -3506,30 +3590,24 @@ export declare interface Inject {
3506
3590
  export declare const Inject: InjectDecorator;
3507
3591
 
3508
3592
  /**
3509
- * Injects a token from the currently active injector.
3510
- *
3511
- * Must be used in the context of a factory function such as one defined for an
3512
- * `InjectionToken`. Throws an error if not called from such a context.
3593
+ * @param token A token that represents a dependency that should be injected.
3594
+ * @returns the injected value if operation is successful, `null` otherwise.
3595
+ * @throws if called outside of a supported context.
3513
3596
  *
3514
- * Within such a factory function, using this function to request injection of a dependency
3515
- * is faster and more type-safe than providing an additional array of dependencies
3516
- * (as has been common with `useFactory` providers).
3517
- *
3518
- * @param token The injection token for the dependency to be injected.
3519
- * @param flags Optional flags that control how injection is executed.
3520
- * The flags correspond to injection strategies that can be specified with
3521
- * parameter decorators `@Host`, `@Self`, `@SkipSef`, and `@Optional`.
3522
- * @returns the injected value if injection is successful, `null` otherwise.
3523
- *
3524
- * @usageNotes
3525
- *
3526
- * ### Example
3527
- *
3528
- * {@example core/di/ts/injector_spec.ts region='ShakableInjectionToken'}
3597
+ * @publicApi
3598
+ */
3599
+ export declare function inject<T>(token: ProviderToken<T>): T;
3600
+
3601
+ /**
3602
+ * @param token A token that represents a dependency that should be injected.
3603
+ * @param flags Control how injection is executed. The flags correspond to injection strategies that
3604
+ * can be specified with parameter decorators `@Host`, `@Self`, `@SkipSelf`, and `@Optional`.
3605
+ * @returns the injected value if operation is successful, `null` otherwise.
3606
+ * @throws if called outside of a supported context.
3529
3607
  *
3530
3608
  * @publicApi
3531
3609
  */
3532
- export declare const inject: typeof ɵɵinject;
3610
+ export declare function inject<T>(token: ProviderToken<T>, flags?: InjectFlags): T | null;
3533
3611
 
3534
3612
  /**
3535
3613
  * Type of the Injectable metadata.
@@ -3611,7 +3689,7 @@ export declare type InjectableProvider = ValueSansProvider | ExistingSansProvide
3611
3689
  * A `Type` which has a `ɵprov: ɵɵInjectableDeclaration` static field.
3612
3690
  *
3613
3691
  * `InjectableType`s contain their own Dependency Injection metadata and are usable in an
3614
- * `InjectorDef`-based `StaticInjector.
3692
+ * `InjectorDef`-based `StaticInjector`.
3615
3693
  *
3616
3694
  * @publicApi
3617
3695
  */
@@ -5570,6 +5648,9 @@ export declare interface Pipe {
5570
5648
  /**
5571
5649
  * Angular pipes marked as `standalone` do not need to be declared in an NgModule. Such
5572
5650
  * pipes don't depend on any "intermediate context" of an NgModule (ex. configured providers).
5651
+ *
5652
+ * More information about standalone components, directives and pipes can be found in [this
5653
+ * guide](guide/standalone-components).
5573
5654
  */
5574
5655
  standalone?: boolean;
5575
5656
  }
@@ -6952,7 +7033,7 @@ declare const enum RuntimeErrorCode {
6952
7033
  CYCLIC_DI_DEPENDENCY = -200,
6953
7034
  PROVIDER_NOT_FOUND = -201,
6954
7035
  INVALID_FACTORY_DEPENDENCY = 202,
6955
- MISSING_INJECTION_CONTEXT = 203,
7036
+ MISSING_INJECTION_CONTEXT = -203,
6956
7037
  INVALID_INJECTION_TOKEN = 204,
6957
7038
  INJECTOR_ALREADY_DESTROYED = 205,
6958
7039
  PROVIDER_IN_WRONG_CONTEXT = 207,
@@ -9693,7 +9774,8 @@ export declare interface ɵComponentDef<T> extends ɵDirectiveDef<T> {
9693
9774
  */
9694
9775
  tView: TView | null;
9695
9776
  /**
9696
- * A function added by the {@see ɵɵStandaloneFeature} and used by the framework to create standalone injectors.
9777
+ * A function added by the {@link ɵɵStandaloneFeature} and used by the framework to create
9778
+ * standalone injectors.
9697
9779
  */
9698
9780
  getStandaloneInjector: ((parentInjector: EnvironmentInjector) => EnvironmentInjector | null) | null;
9699
9781
  /**
@@ -12565,10 +12647,7 @@ export declare function ɵɵi18nStart(index: number, messageIndex: number, subTe
12565
12647
  export declare function ɵɵInheritDefinitionFeature(definition: ɵDirectiveDef<any> | ɵComponentDef<any>): void;
12566
12648
 
12567
12649
  /**
12568
- * Generated instruction: Injects a token from the currently active injector.
12569
- *
12570
- * Must be used in the context of a factory function such as one defined for an
12571
- * `InjectionToken`. Throws an error if not called from such a context.
12650
+ * Generated instruction: injects a token from the currently active injector.
12572
12651
  *
12573
12652
  * (Additional documentation moved to `inject`, as it is the public API, and an alias for this
12574
12653
  * instruction)
@@ -13752,7 +13831,7 @@ export declare function ɵɵsanitizeUrlOrResourceUrl(unsafeUrl: any, tag: string
13752
13831
  *
13753
13832
  * @codeGenApi
13754
13833
  */
13755
- export declare function ɵɵsetComponentScope(type: ɵComponentType<any>, directives: Type<any>[], pipes: Type<any>[]): void;
13834
+ export declare function ɵɵsetComponentScope(type: ɵComponentType<any>, directives: Type<any>[] | (() => Type<any>[]), pipes: Type<any>[] | (() => Type<any>[])): void;
13756
13835
 
13757
13836
  /**
13758
13837
  * Adds the module metadata that is necessary to compute the module's transitive scope to an
@@ -13777,7 +13856,7 @@ export declare function ɵɵsetNgModuleScope(type: any, scope: {
13777
13856
  }): unknown;
13778
13857
 
13779
13858
  /**
13780
- * A feature that acts as a setup code for the {@see StandaloneService}.
13859
+ * A feature that acts as a setup code for the {@link StandaloneService}.
13781
13860
  *
13782
13861
  * The most important responsaibility of this feature is to expose the "getStandaloneInjector"
13783
13862
  * function (an entry points to a standalone injector creation) on a component definition object. We
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/core",
3
- "version": "14.0.0-rc.1",
3
+ "version": "14.0.0",
4
4
  "description": "Angular - the core framework",
5
5
  "author": "angular",
6
6
  "license": "MIT",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.0.0-rc.1
2
+ * @license Angular v14.0.0
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -187,7 +187,10 @@ export declare function flushMicrotasks(): void;
187
187
  export declare const getTestBed: () => TestBed;
188
188
 
189
189
  /**
190
- * Allows injecting dependencies in `beforeEach()` and `it()`.
190
+ * Allows injecting dependencies in `beforeEach()` and `it()`. Note: this function
191
+ * (imported from the `@angular/core/testing` package) can **only** be used to inject dependencies
192
+ * in tests. To inject dependencies in your application code, use the [`inject`](api/core/inject)
193
+ * function from the `@angular/core` package instead.
191
194
  *
192
195
  * Example:
193
196
  *