@angular/core 14.0.0-rc.0 → 14.0.0-rc.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.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.0.0-rc.0
2
+ * @license Angular v14.0.0-rc.3
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1026,6 +1026,9 @@ 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).
1029
1032
  */
1030
1033
  standalone?: boolean;
1031
1034
  /**
@@ -1035,6 +1038,9 @@ export declare interface Component extends Directive {
1035
1038
  *
1036
1039
  * This property is only available for standalone components - specifying it for components
1037
1040
  * declared in an NgModule generates a compilation error.
1041
+ *
1042
+ * More information about standalone components, directives and pipes can be found in [this
1043
+ * guide](guide/standalone-components).
1038
1044
  */
1039
1045
  imports?: (Type<any> | any[])[];
1040
1046
  /**
@@ -1043,6 +1049,9 @@ export declare interface Component extends Directive {
1043
1049
  *
1044
1050
  * This property is only available for standalone components - specifying it for components
1045
1051
  * declared in an NgModule generates a compilation error.
1052
+ *
1053
+ * More information about standalone components, directives and pipes can be found in [this
1054
+ * guide](guide/standalone-components).
1046
1055
  */
1047
1056
  schemas?: SchemaMetadata[];
1048
1057
  }
@@ -2271,6 +2280,9 @@ export declare interface Directive {
2271
2280
  * Angular directives marked as `standalone` do not need to be declared in an NgModule. Such
2272
2281
  * directives don't depend on any "intermediate context" of an NgModule (ex. configured
2273
2282
  * providers).
2283
+ *
2284
+ * More information about standalone components, directives and pipes can be found in [this
2285
+ * guide](guide/standalone-components).
2274
2286
  */
2275
2287
  standalone?: boolean;
2276
2288
  }
@@ -2315,21 +2327,53 @@ export declare interface DirectiveDecorator {
2315
2327
  *
2316
2328
  * ### Declaring directives
2317
2329
  *
2318
- * Directives are [declarables](guide/glossary#declarable).
2319
- * They must be declared by an NgModule
2320
- * in order to be usable in an app.
2330
+ * In order to make a directive available to other components in your application, you should do
2331
+ * one of the following:
2332
+ * - either mark the directive as [standalone](guide/standalone-components),
2333
+ * - or declare it in an NgModule by adding it to the `declarations` and `exports` fields.
2334
+ *
2335
+ * ** Marking a directive as standalone **
2321
2336
  *
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.
2337
+ * You can add the `standalone: true` flag to the Directive decorator metadata to declare it as
2338
+ * [standalone](guide/standalone-components):
2325
2339
  *
2326
2340
  * ```ts
2327
- * declarations: [
2328
- * AppComponent,
2329
- * MyDirective
2330
- * ],
2341
+ * @Directive({
2342
+ * standalone: true,
2343
+ * selector: 'my-directive',
2344
+ * })
2345
+ * class MyDirective {}
2331
2346
  * ```
2332
2347
  *
2348
+ * When marking a directive as standalone, please make sure that the directive is not already
2349
+ * declared in an NgModule.
2350
+ *
2351
+ *
2352
+ * ** Declaring a directive in an NgModule **
2353
+ *
2354
+ * Another approach is to declare a directive in an NgModule:
2355
+ *
2356
+ * ```ts
2357
+ * @Directive({
2358
+ * selector: 'my-directive',
2359
+ * })
2360
+ * class MyDirective {}
2361
+ *
2362
+ * @NgModule({
2363
+ * declarations: [MyDirective, SomeComponent],
2364
+ * exports: [MyDirective], // making it available outside of this module
2365
+ * })
2366
+ * class SomeNgModule {}
2367
+ * ```
2368
+ *
2369
+ * When declaring a directive in an NgModule, please make sure that:
2370
+ * - the directive is declared in exactly one NgModule.
2371
+ * - the directive is not standalone.
2372
+ * - you do not re-declare a directive imported from another module.
2373
+ * - the directive is included into the `exports` field as well if you want this directive to be
2374
+ * accessible for components outside of the NgModule.
2375
+ *
2376
+ *
2333
2377
  * @Annotation
2334
2378
  */
2335
2379
  (obj?: Directive): TypeDecorator;
@@ -3506,30 +3550,24 @@ export declare interface Inject {
3506
3550
  export declare const Inject: InjectDecorator;
3507
3551
 
3508
3552
  /**
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.
3513
- *
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
3553
+ * @param token A token that represents a dependency that should be injected.
3554
+ * @returns the injected value if operation is successful, `null` otherwise.
3555
+ * @throws if called outside of a supported context.
3525
3556
  *
3526
- * ### Example
3527
- *
3528
- * {@example core/di/ts/injector_spec.ts region='ShakableInjectionToken'}
3557
+ * @publicApi
3558
+ */
3559
+ export declare function inject<T>(token: ProviderToken<T>): T;
3560
+
3561
+ /**
3562
+ * @param token A token that represents a dependency that should be injected.
3563
+ * @param flags Control how injection is executed. The flags correspond to injection strategies that
3564
+ * can be specified with parameter decorators `@Host`, `@Self`, `@SkipSelf`, and `@Optional`.
3565
+ * @returns the injected value if operation is successful, `null` otherwise.
3566
+ * @throws if called outside of a supported context.
3529
3567
  *
3530
3568
  * @publicApi
3531
3569
  */
3532
- export declare const inject: typeof ɵɵinject;
3570
+ export declare function inject<T>(token: ProviderToken<T>, flags?: InjectFlags): T | null;
3533
3571
 
3534
3572
  /**
3535
3573
  * Type of the Injectable metadata.
@@ -3611,7 +3649,7 @@ export declare type InjectableProvider = ValueSansProvider | ExistingSansProvide
3611
3649
  * A `Type` which has a `ɵprov: ɵɵInjectableDeclaration` static field.
3612
3650
  *
3613
3651
  * `InjectableType`s contain their own Dependency Injection metadata and are usable in an
3614
- * `InjectorDef`-based `StaticInjector.
3652
+ * `InjectorDef`-based `StaticInjector`.
3615
3653
  *
3616
3654
  * @publicApi
3617
3655
  */
@@ -5570,6 +5608,9 @@ export declare interface Pipe {
5570
5608
  /**
5571
5609
  * Angular pipes marked as `standalone` do not need to be declared in an NgModule. Such
5572
5610
  * pipes don't depend on any "intermediate context" of an NgModule (ex. configured providers).
5611
+ *
5612
+ * More information about standalone components, directives and pipes can be found in [this
5613
+ * guide](guide/standalone-components).
5573
5614
  */
5574
5615
  standalone?: boolean;
5575
5616
  }
@@ -6952,7 +6993,7 @@ declare const enum RuntimeErrorCode {
6952
6993
  CYCLIC_DI_DEPENDENCY = -200,
6953
6994
  PROVIDER_NOT_FOUND = -201,
6954
6995
  INVALID_FACTORY_DEPENDENCY = 202,
6955
- MISSING_INJECTION_CONTEXT = 203,
6996
+ MISSING_INJECTION_CONTEXT = -203,
6956
6997
  INVALID_INJECTION_TOKEN = 204,
6957
6998
  INJECTOR_ALREADY_DESTROYED = 205,
6958
6999
  PROVIDER_IN_WRONG_CONTEXT = 207,
@@ -9693,7 +9734,8 @@ export declare interface ɵComponentDef<T> extends ɵDirectiveDef<T> {
9693
9734
  */
9694
9735
  tView: TView | null;
9695
9736
  /**
9696
- * A function added by the {@see ɵɵStandaloneFeature} and used by the framework to create standalone injectors.
9737
+ * A function added by the {@link ɵɵStandaloneFeature} and used by the framework to create
9738
+ * standalone injectors.
9697
9739
  */
9698
9740
  getStandaloneInjector: ((parentInjector: EnvironmentInjector) => EnvironmentInjector | null) | null;
9699
9741
  /**
@@ -12565,10 +12607,7 @@ export declare function ɵɵi18nStart(index: number, messageIndex: number, subTe
12565
12607
  export declare function ɵɵInheritDefinitionFeature(definition: ɵDirectiveDef<any> | ɵComponentDef<any>): void;
12566
12608
 
12567
12609
  /**
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.
12610
+ * Generated instruction: injects a token from the currently active injector.
12572
12611
  *
12573
12612
  * (Additional documentation moved to `inject`, as it is the public API, and an alias for this
12574
12613
  * instruction)
@@ -13752,7 +13791,7 @@ export declare function ɵɵsanitizeUrlOrResourceUrl(unsafeUrl: any, tag: string
13752
13791
  *
13753
13792
  * @codeGenApi
13754
13793
  */
13755
- export declare function ɵɵsetComponentScope(type: ɵComponentType<any>, directives: Type<any>[], pipes: Type<any>[]): void;
13794
+ export declare function ɵɵsetComponentScope(type: ɵComponentType<any>, directives: Type<any>[] | (() => Type<any>[]), pipes: Type<any>[] | (() => Type<any>[])): void;
13756
13795
 
13757
13796
  /**
13758
13797
  * Adds the module metadata that is necessary to compute the module's transitive scope to an
@@ -13777,7 +13816,7 @@ export declare function ɵɵsetNgModuleScope(type: any, scope: {
13777
13816
  }): unknown;
13778
13817
 
13779
13818
  /**
13780
- * A feature that acts as a setup code for the {@see StandaloneService}.
13819
+ * A feature that acts as a setup code for the {@link StandaloneService}.
13781
13820
  *
13782
13821
  * The most important responsaibility of this feature is to expose the "getStandaloneInjector"
13783
13822
  * 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.0",
3
+ "version": "14.0.0-rc.3",
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.0
2
+ * @license Angular v14.0.0-rc.3
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
  *