static-injector 2.1.0 → 2.2.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.
Files changed (108) hide show
  1. package/import/commonjs/index.js +403 -211
  2. package/import/{es2015 → es2022}/di/create_injector.js +5 -3
  3. package/import/{es2015 → es2022}/di/forward_ref.js +32 -5
  4. package/import/{es2015 → es2022}/di/injection_token.js +20 -11
  5. package/import/{es2015 → es2022}/di/injector.js +15 -16
  6. package/import/{es2015 → es2022}/di/injector_compatibility.js +27 -13
  7. package/import/{es2015 → es2022}/di/injector_token.js +3 -3
  8. package/import/{es2015 → es2022}/di/interface/defs.js +22 -27
  9. package/import/{es2015 → es2022}/di/interface/injector.js +1 -1
  10. package/import/{es2015 → es2022}/di/interface/provider.js +3 -1
  11. package/import/{es2015 → es2022}/di/null_injector.js +3 -3
  12. package/import/es2022/di/provider_collection.js +104 -0
  13. package/import/{es2015 → es2022}/di/r3_injector.js +71 -37
  14. package/import/es2022/error_details_base_url.js +19 -0
  15. package/import/es2022/errors.js +44 -0
  16. package/import/es2022/interface/type.js +21 -0
  17. package/import/{es2015 → es2022}/render3/definition_factory.js +2 -3
  18. package/import/{es2015 → es2022}/render3/error_code.js +1 -0
  19. package/import/{es2015 → es2022}/render3/errors_di.js +2 -3
  20. package/import/es2022/render3/fields.js +22 -0
  21. package/import/{es2015 → es2022}/render3/instructions/di.js +0 -7
  22. package/import/{es2015 → es2022}/render3/util/stringify_utils.js +5 -5
  23. package/import/{es2015 → es2022}/util/array_utils.js +0 -7
  24. package/import/es2022/util/decorators.js +53 -0
  25. package/import/{es2015 → es2022}/util/empty.js +4 -0
  26. package/import/{es2015 → es2022}/util/stringify.js +5 -5
  27. package/import/{fesm2015 → fesm2022}/index.js +399 -209
  28. package/import/typings/di/create_injector.d.ts +3 -5
  29. package/import/typings/di/forward_ref.d.ts +30 -3
  30. package/import/typings/di/inject_switch.d.ts +1 -1
  31. package/import/typings/di/injectable.d.ts +4 -3
  32. package/import/typings/di/injection_token.d.ts +21 -6
  33. package/import/typings/di/injector.d.ts +19 -3
  34. package/import/typings/di/injector_compatibility.d.ts +12 -5
  35. package/import/typings/di/injector_token.d.ts +2 -2
  36. package/import/typings/di/interface/defs.d.ts +17 -9
  37. package/import/typings/di/interface/injector.d.ts +2 -2
  38. package/import/typings/di/interface/provider.d.ts +64 -4
  39. package/import/typings/di/metadata.d.ts +4 -4
  40. package/import/typings/di/null_injector.d.ts +1 -1
  41. package/import/typings/di/provider_collection.d.ts +53 -11
  42. package/import/typings/di/provider_token.d.ts +2 -2
  43. package/import/typings/di/r3_injector.d.ts +11 -14
  44. package/import/typings/di/scope.d.ts +1 -1
  45. package/import/typings/error_details_base_url.d.ts +19 -0
  46. package/import/typings/errors.d.ts +114 -0
  47. package/import/typings/interface/type.d.ts +45 -0
  48. package/import/typings/render3/errors_di.d.ts +7 -0
  49. package/import/typings/render3/fields.d.ts +9 -0
  50. package/import/typings/render3/instructions/di.d.ts +0 -7
  51. package/import/typings/util/array_utils.d.ts +15 -7
  52. package/import/typings/util/decorators.d.ts +3 -1
  53. package/import/typings/util/empty.d.ts +1 -0
  54. package/package.json +7 -7
  55. package/readme.md +4 -1
  56. package/transform/compiler/src/injectable_compiler_2.d.ts +0 -1
  57. package/transform/compiler/src/injectable_compiler_2.js +31 -16
  58. package/transform/compiler/src/output/output_ast.d.ts +53 -10
  59. package/transform/compiler/src/output/output_ast.js +211 -12
  60. package/transform/compiler/src/parse_util.js +10 -0
  61. package/transform/compiler/src/render3/partial/api.js +1 -1
  62. package/transform/compiler/src/render3/r3_factory.d.ts +0 -8
  63. package/transform/compiler/src/render3/r3_factory.js +5 -4
  64. package/transform/compiler/src/render3/r3_identifiers.js +37 -37
  65. package/transform/compiler/src/render3/view/util.js +1 -3
  66. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +2 -4
  67. package/transform/compiler-cli/src/ngtsc/annotations/common/src/factory.js +1 -0
  68. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.d.ts +1 -1
  69. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +5 -9
  70. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +2 -1
  71. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +12 -8
  72. package/transform/compiler-cli/src/ngtsc/diagnostics/error.d.ts +2 -2
  73. package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +8 -4
  74. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.js +1 -1
  75. package/transform/compiler-cli/src/ngtsc/imports/src/default.js +1 -2
  76. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +24 -173
  77. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +2 -51
  78. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +5 -3
  79. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +5 -10
  80. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +5 -23
  81. package/transform/compiler-cli/src/ngtsc/transform/src/api.js +0 -21
  82. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +1 -2
  83. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +7 -0
  84. package/transform/compiler-cli/src/ngtsc/translator/src/context.js +1 -0
  85. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +4 -2
  86. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +1 -0
  87. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +10 -4
  88. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +2 -1
  89. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +20 -16
  90. package/transform/injectable-transform.d.ts +2 -2
  91. package/transform/injectable-transform.js +32 -6
  92. package/import/es2015/di/provider_collection.js +0 -49
  93. package/import/es2015/interface/type.js +0 -8
  94. package/import/es2015/render3/fields.js +0 -11
  95. package/import/es2015/util/decorators.js +0 -30
  96. /package/import/{es2015 → es2022}/di/initializer_token.js +0 -0
  97. /package/import/{es2015 → es2022}/di/inject_switch.js +0 -0
  98. /package/import/{es2015 → es2022}/di/injectable.js +0 -0
  99. /package/import/{es2015 → es2022}/di/injector_marker.js +0 -0
  100. /package/import/{es2015 → es2022}/di/internal_tokens.js +0 -0
  101. /package/import/{es2015 → es2022}/di/metadata.js +0 -0
  102. /package/import/{es2015 → es2022}/di/provider_token.js +0 -0
  103. /package/import/{es2015 → es2022}/di/scope.js +0 -0
  104. /package/import/{es2015 → es2022}/index.js +0 -0
  105. /package/import/{es2015 → es2022}/interface/lifecycle_hooks.js +0 -0
  106. /package/import/{es2015 → es2022}/render3/di.js +0 -0
  107. /package/import/{es2015 → es2022}/util/closure.js +0 -0
  108. /package/import/{es2015 → es2022}/util/property.js +0 -0
@@ -6,18 +6,16 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { Injector } from './injector';
9
- import { StaticProvider } from './interface/provider';
9
+ import { Provider, StaticProvider } from './interface/provider';
10
10
  import { R3Injector } from './r3_injector';
11
11
  import { InjectorScope } from './scope';
12
12
  /**
13
13
  * Create a new `Injector` which is configured using a `defType` of `InjectorType<any>`s.
14
- *
15
- * @publicApi
16
14
  */
17
- export declare function createInjector(defType: any, parent?: Injector | null, additionalProviders?: StaticProvider[] | null, name?: string): Injector;
15
+ export declare function createInjector(defType: any, parent?: Injector | null, additionalProviders?: Array<Provider | StaticProvider> | null, name?: string): Injector;
18
16
  /**
19
17
  * Creates a new injector without eagerly resolving its injector types. Can be used in places
20
18
  * where resolving the injector types immediately can lead to an infinite loop. The injector types
21
19
  * should be resolved at a later point by calling `_resolveInjectorDefTypes`.
22
20
  */
23
- export declare function createInjectorWithoutInjectorInstances(defType: any, parent?: Injector | null, additionalProviders?: StaticProvider[] | null, name?: string, scopes?: Set<InjectorScope>): R3Injector;
21
+ export declare function createInjectorWithoutInjectorInstances(defType: any, parent?: Injector | null, additionalProviders?: Array<Provider | StaticProvider> | null, name?: string, scopes?: Set<InjectorScope>): R3Injector;
@@ -5,7 +5,7 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { Type } from "../interface/type";
8
+ import { Type } from '../interface/type';
9
9
  /**
10
10
  * An interface that a function passed into {@link forwardRef} has to implement.
11
11
  *
@@ -25,9 +25,36 @@ export interface ForwardRefFn {
25
25
  * DI is declared, but not yet defined. It is also used when the `token` which we use when creating
26
26
  * a query is not yet defined.
27
27
  *
28
+ * `forwardRef` is also used to break circularities in standalone components imports.
29
+ *
28
30
  * @usageNotes
29
- * ### Example
31
+ * ### Circular dependency example
30
32
  * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
33
+ *
34
+ * ### Circular standalone reference import example
35
+ * ```ts
36
+ * @Component({
37
+ * standalone: true,
38
+ * imports: [ChildComponent],
39
+ * selector: 'app-parent',
40
+ * template: `<app-child [hideParent]="hideParent"></app-child>`,
41
+ * })
42
+ * export class ParentComponent {
43
+ * @Input() hideParent: boolean;
44
+ * }
45
+ *
46
+ *
47
+ * @Component({
48
+ * standalone: true,
49
+ * imports: [CommonModule, forwardRef(() => ParentComponent)],
50
+ * selector: 'app-child',
51
+ * template: `<app-parent *ngIf="!hideParent"></app-parent>`,
52
+ * })
53
+ * export class ChildComponent {
54
+ * @Input() hideParent: boolean;
55
+ * }
56
+ * ```
57
+ *
31
58
  * @publicApi
32
59
  */
33
60
  export declare function forwardRef(forwardRefFn: ForwardRefFn): Type<any>;
@@ -41,7 +68,7 @@ export declare function forwardRef(forwardRefFn: ForwardRefFn): Type<any>;
41
68
  *
42
69
  * {@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
43
70
  *
44
- * @see `forwardRef`
71
+ * @see {@link forwardRef}
45
72
  * @publicApi
46
73
  */
47
74
  export declare function resolveForwardRef<T>(type: T): T;
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { InjectFlags } from './interface/injector';
9
9
  import { ProviderToken } from './provider_token';
10
- export declare function getInjectImplementation(): <T>(token: ProviderToken<T>, flags?: InjectFlags) => T;
10
+ export declare function getInjectImplementation(): (<T>(token: ProviderToken<T>, flags?: InjectFlags | undefined) => T | null) | undefined;
11
11
  /**
12
12
  * Sets the current inject implementation.
13
13
  */
@@ -5,9 +5,9 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { ValueSansProvider, ExistingSansProvider, StaticClassSansProvider, ConstructorSansProvider, FactorySansProvider, ClassSansProvider } from './interface/provider';
9
8
  import { Type } from '../interface/type';
10
9
  import { TypeDecorator } from '../util/decorators';
10
+ import { ClassSansProvider, ConstructorSansProvider, ExistingSansProvider, FactorySansProvider, StaticClassSansProvider, ValueSansProvider } from './interface/provider';
11
11
  /**
12
12
  * Injectable providers used in `@Injectable` decorator.
13
13
  *
@@ -57,7 +57,8 @@ export interface Injectable {
57
57
  /**
58
58
  * Determines which injectors will provide the injectable.
59
59
  *
60
- * - `Type<any>` - associates the injectable with an `@NgModule` or other `InjectorType`,
60
+ * - `Type<any>` - associates the injectable with an `@NgModule` or other `InjectorType`. This
61
+ * option is DEPRECATED.
61
62
  * - 'null' : Equivalent to `undefined`. The injectable is not provided in any scope automatically
62
63
  * and must be added to a `providers` array of an [@NgModule](api/core/NgModule#providers),
63
64
  * [@Component](api/core/Directive#providers) or [@Directive](api/core/Directive#providers).
@@ -68,7 +69,7 @@ export interface Injectable {
68
69
  * - 'platform' : A special singleton platform injector shared by all
69
70
  * applications on the page.
70
71
  * - 'any' : Provides a unique instance in each lazy loaded module while all eagerly loaded
71
- * modules share one instance.
72
+ * modules share one instance. This option is DEPRECATED.
72
73
  *
73
74
  */
74
75
  providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
@@ -14,11 +14,11 @@ import { Type } from '../interface/type';
14
14
  * parameterized type.
15
15
  *
16
16
  * `InjectionToken` is parameterized on `T` which is the type of object which will be returned by
17
- * the `Injector`. This provides additional level of type safety.
17
+ * the `Injector`. This provides an additional level of type safety.
18
18
  *
19
19
  * ```
20
20
  * interface MyInterface {...}
21
- * var myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
21
+ * const myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
22
22
  * // myInterface is inferred to be MyInterface.
23
23
  * ```
24
24
  *
@@ -26,14 +26,18 @@ import { Type } from '../interface/type';
26
26
  * (possibly by creating) a default value of the parameterized type `T`. This sets up the
27
27
  * `InjectionToken` using this factory as a provider as if it was defined explicitly in the
28
28
  * application's root injector. If the factory function, which takes zero arguments, needs to inject
29
- * dependencies, it can do so using the `inject` function. See below for an example.
29
+ * dependencies, it can do so using the [`inject`](api/core/inject) function.
30
+ * As you can see in the Tree-shakable InjectionToken example below.
30
31
  *
31
32
  * Additionally, if a `factory` is specified you can also specify the `providedIn` option, which
32
- * overrides the above behavior and marks the token as belonging to a particular `@NgModule`. As
33
- * mentioned above, `'root'` is the default value for `providedIn`.
33
+ * overrides the above behavior and marks the token as belonging to a particular `@NgModule` (note:
34
+ * this option is now deprecated). As mentioned above, `'root'` is the default value for
35
+ * `providedIn`.
36
+ *
37
+ * The `providedIn: NgModule` and `providedIn: 'any'` options are deprecated.
34
38
  *
35
39
  * @usageNotes
36
- * ### Basic Example
40
+ * ### Basic Examples
37
41
  *
38
42
  * ### Plain InjectionToken
39
43
  *
@@ -48,7 +52,15 @@ import { Type } from '../interface/type';
48
52
  */
49
53
  export declare class InjectionToken<T> {
50
54
  protected _desc: string;
55
+ /** @internal */
56
+ readonly ngMetadataName = "InjectionToken";
51
57
  readonly ɵprov: unknown;
58
+ /**
59
+ * @param _desc Description for the token,
60
+ * used only for debugging purposes,
61
+ * it should but does not need to be unique
62
+ * @param options Options for the token's usage, as described above
63
+ */
52
64
  constructor(_desc: string, options?: {
53
65
  providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
54
66
  factory: () => T;
@@ -59,3 +71,6 @@ export declare class InjectionToken<T> {
59
71
  get multi(): InjectionToken<Array<T>>;
60
72
  toString(): string;
61
73
  }
74
+ export interface InjectableDefToken<T> extends InjectionToken<T> {
75
+ ɵprov: unknown;
76
+ }
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { InjectorMarkers } from './injector_marker';
9
9
  import { InjectFlags, InjectOptions } from './interface/injector';
10
- import { StaticProvider } from './interface/provider';
10
+ import { Provider, StaticProvider } from './interface/provider';
11
11
  import { ProviderToken } from './provider_token';
12
12
  /**
13
13
  * Concrete injectors implement this interface. Injectors are configured
@@ -15,7 +15,7 @@ import { ProviderToken } from './provider_token';
15
15
  * dependencies of various types with [injection tokens](guide/glossary#di-token).
16
16
  *
17
17
  * @see ["DI Providers"](guide/dependency-injection-providers).
18
- * @see `StaticProvider`
18
+ * @see {@link StaticProvider}
19
19
  *
20
20
  * @usageNotes
21
21
  *
@@ -62,6 +62,22 @@ export declare abstract class Injector {
62
62
  * @throws When the `notFoundValue` is `undefined` or `Injector.THROW_IF_NOT_FOUND`.
63
63
  */
64
64
  abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, options?: InjectOptions | InjectFlags): T;
65
+ /**
66
+ * Retrieves an instance from the injector based on the provided token.
67
+ * @returns The instance from the injector if defined, otherwise the `notFoundValue`.
68
+ * @throws When the `notFoundValue` is `undefined` or `Injector.THROW_IF_NOT_FOUND`.
69
+ * @deprecated use object-based flags (`InjectOptions`) instead.
70
+ */
71
+ abstract get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
72
+ /**
73
+ * @deprecated from v4.0.0 use ProviderToken<T>
74
+ * @suppress {duplicate}
75
+ */
76
+ abstract get(token: any, notFoundValue?: any): any;
77
+ /**
78
+ * @deprecated from v5 use the new signature Injector.create(options)
79
+ */
80
+ static create(providers: StaticProvider[], parent?: Injector): Injector;
65
81
  /**
66
82
  * Creates a new injector instance that provides one or more dependencies,
67
83
  * according to a given type or types of `StaticProvider`.
@@ -75,7 +91,7 @@ export declare abstract class Injector {
75
91
  *
76
92
  */
77
93
  static create(options: {
78
- providers: StaticProvider[];
94
+ providers: Array<Provider | StaticProvider>;
79
95
  parent?: Injector;
80
96
  name?: string;
81
97
  }): Injector;
@@ -11,15 +11,12 @@ import { ProviderToken } from './provider_token';
11
11
  export declare const THROW_IF_NOT_FOUND: {};
12
12
  export declare const NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
13
13
  export declare const SOURCE = "__source";
14
- export declare const USE_VALUE: string;
14
+ export declare function getCurrentInjector(): Injector | undefined | null;
15
15
  export declare function setCurrentInjector(injector: Injector | null | undefined): Injector | undefined | null;
16
16
  export declare function injectInjectorOnly<T>(token: ProviderToken<T>): T;
17
17
  export declare function injectInjectorOnly<T>(token: ProviderToken<T>, flags?: InjectFlags): T | null;
18
18
  /**
19
- * Generated instruction: Injects a token from the currently active injector.
20
- *
21
- * Must be used in the context of a factory function such as one defined for an
22
- * `InjectionToken`. Throws an error if not called from such a context.
19
+ * Generated instruction: injects a token from the currently active injector.
23
20
  *
24
21
  * (Additional documentation moved to `inject`, as it is the public API, and an alias for this
25
22
  * instruction)
@@ -30,6 +27,16 @@ export declare function injectInjectorOnly<T>(token: ProviderToken<T>, flags?: I
30
27
  */
31
28
  export declare function ɵɵinject<T>(token: ProviderToken<T>): T;
32
29
  export declare function ɵɵinject<T>(token: ProviderToken<T>, flags?: InjectFlags): T | null;
30
+ /**
31
+ * Throws an error indicating that a factory function could not be generated by the compiler for a
32
+ * particular class.
33
+ *
34
+ * The name of the class is not mentioned here, but will be in the generated factory function name
35
+ * and thus in the stack trace.
36
+ *
37
+ * @codeGenApi
38
+ */
39
+ export declare function ɵɵinvalidFactoryDep(index: number): void;
33
40
  /**
34
41
  * @param token A token that represents a dependency that should be injected.
35
42
  * @returns the injected value if operation is successful, `null` otherwise.
@@ -5,8 +5,8 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { InjectionToken } from "./injection_token";
9
- import { Injector } from "./injector";
8
+ import { InjectionToken } from './injection_token';
9
+ import { Injector } from './injector';
10
10
  /**
11
11
  * An InjectionToken that gets the current `Injector` for `createInjector()`-style injectors.
12
12
  *
@@ -6,7 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { Type } from '../../interface/type';
9
- import { ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, ValueProvider } from './provider';
9
+ import { ClassProvider, ConstructorProvider, EnvironmentProviders, ExistingProvider, FactoryProvider, StaticClassProvider, ValueProvider } from './provider';
10
10
  /**
11
11
  * Information about how a type or `InjectionToken` interfaces with the DI system.
12
12
  *
@@ -31,7 +31,7 @@ export interface ɵɵInjectableDeclaration<T> {
31
31
  * - `null`, does not belong to any injector. Must be explicitly listed in the injector
32
32
  * `providers`.
33
33
  */
34
- providedIn: InjectorType<any> | 'root' | 'platform' | 'any' | null;
34
+ providedIn: InjectorType<any> | 'root' | 'platform' | 'any' | 'environment' | null;
35
35
  /**
36
36
  * The token to which this definition belongs.
37
37
  *
@@ -60,14 +60,14 @@ export interface ɵɵInjectableDeclaration<T> {
60
60
  * @codeGenApi
61
61
  */
62
62
  export interface ɵɵInjectorDef<T> {
63
- providers: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[];
63
+ providers: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | EnvironmentProviders | any[])[];
64
64
  imports: (InjectorType<any> | InjectorTypeWithProviders<any>)[];
65
65
  }
66
66
  /**
67
67
  * A `Type` which has a `ɵprov: ɵɵInjectableDeclaration` static field.
68
68
  *
69
69
  * `InjectableType`s contain their own Dependency Injection metadata and are usable in an
70
- * `InjectorDef`-based `StaticInjector.
70
+ * `InjectorDef`-based `StaticInjector`.
71
71
  *
72
72
  * @publicApi
73
73
  */
@@ -100,7 +100,7 @@ export interface InjectorType<T> extends Type<T> {
100
100
  */
101
101
  export interface InjectorTypeWithProviders<T> {
102
102
  ngModule: InjectorType<T>;
103
- providers?: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | any[])[];
103
+ providers?: (Type<any> | ValueProvider | ExistingProvider | FactoryProvider | ConstructorProvider | StaticClassProvider | ClassProvider | EnvironmentProviders | any[])[];
104
104
  }
105
105
  /**
106
106
  * Construct an injectable definition which defines how a token will be constructed by the DI
@@ -114,14 +114,15 @@ export interface InjectorTypeWithProviders<T> {
114
114
  * with an `@NgModule` or other `InjectorType`, or by specifying that this injectable should be
115
115
  * provided in the `'root'` injector, which will be the application-level injector in most apps.
116
116
  * * `factory` gives the zero argument function which will create an instance of the injectable.
117
- * The factory can call `inject` to access the `Injector` and request injection of dependencies.
117
+ * The factory can call [`inject`](api/core/inject) to access the `Injector` and request injection
118
+ * of dependencies.
118
119
  *
119
120
  * @codeGenApi
120
121
  * @publicApi This instruction has been emitted by ViewEngine for some time and is deployed to npm.
121
122
  */
122
123
  export declare function ɵɵdefineInjectable<T>(opts: {
123
124
  token: unknown;
124
- providedIn?: Type<any> | 'root' | 'platform' | 'any' | null;
125
+ providedIn?: Type<any> | 'root' | 'platform' | 'any' | 'environment' | null;
125
126
  factory: () => T;
126
127
  }): unknown;
127
128
  /**
@@ -152,7 +153,7 @@ export declare function ɵɵdefineInjector(options: {
152
153
  * @param type A type which may have its own (non-inherited) `ɵprov`.
153
154
  */
154
155
  export declare function getInjectableDef<T>(type: any): ɵɵInjectableDeclaration<T> | null;
155
- export declare const NG_PROV_DEF: string;
156
+ export declare function isInjectable(type: any): boolean;
156
157
  /**
157
158
  * Read the injectable def (`ɵprov`) for `type` or read the `ɵprov` from one of its ancestors.
158
159
  *
@@ -162,4 +163,11 @@ export declare const NG_PROV_DEF: string;
162
163
  * scenario if we find the `ɵprov` on an ancestor only.
163
164
  */
164
165
  export declare function getInheritedInjectableDef<T>(type: any): ɵɵInjectableDeclaration<T> | null;
165
- export declare const NG_INJECTABLE_DEF: string;
166
+ /**
167
+ * Read the injector def type in a way which is immune to accidentally reading inherited value.
168
+ *
169
+ * @param type type which may have an injector def (`ɵinj`)
170
+ */
171
+ export declare function getInjectorDef<T>(type: any): ɵɵInjectorDef<T> | null;
172
+ export declare const NG_PROV_DEF: string;
173
+ export declare const NG_INJ_DEF: string;
@@ -17,7 +17,7 @@ export declare const enum DecoratorFlags {
17
17
  * Injection flags for DI.
18
18
  *
19
19
  * @publicApi
20
- * @deprecated use an options object for `inject` instead.
20
+ * @deprecated use an options object for [`inject`](api/core/inject) instead.
21
21
  */
22
22
  export declare enum InjectFlags {
23
23
  /** Check self and check parent injector if needed */
@@ -48,7 +48,7 @@ export declare const enum InternalInjectFlags {
48
48
  Optional = 8
49
49
  }
50
50
  /**
51
- * Type of the options argument to `inject`.
51
+ * Type of the options argument to [`inject`](api/core/inject).
52
52
  *
53
53
  * @publicApi
54
54
  */
@@ -141,7 +141,7 @@ export interface ConstructorProvider extends ConstructorSansProvider {
141
141
  /**
142
142
  * Configures the `Injector` to return a value of another `useExisting` token.
143
143
  *
144
- * @see `ExistingProvider`
144
+ * @see {@link ExistingProvider}
145
145
  * @see ["Dependency Injection Guide"](guide/dependency-injection).
146
146
  *
147
147
  * @publicApi
@@ -181,7 +181,7 @@ export interface ExistingProvider extends ExistingSansProvider {
181
181
  /**
182
182
  * Configures the `Injector` to return a value by invoking a `useFactory` function.
183
183
  *
184
- * @see `FactoryProvider`
184
+ * @see {@link FactoryProvider}
185
185
  * @see ["Dependency Injection Guide"](guide/dependency-injection).
186
186
  *
187
187
  * @publicApi
@@ -231,7 +231,7 @@ export interface FactoryProvider extends FactorySansProvider {
231
231
  * Describes how an `Injector` should be configured as static (that is, without reflection).
232
232
  * A static provider provides tokens to an injector for various types of dependencies.
233
233
  *
234
- * @see `Injector.create()`.
234
+ * @see {@link Injector.create()}
235
235
  * @see ["Dependency Injection Guide"](guide/dependency-injection-providers).
236
236
  *
237
237
  * @publicApi
@@ -300,8 +300,68 @@ export interface ClassProvider extends ClassSansProvider {
300
300
  * Describes how the `Injector` should be configured.
301
301
  * @see ["Dependency Injection Guide"](guide/dependency-injection).
302
302
  *
303
- * @see `StaticProvider`
303
+ * @see {@link StaticProvider}
304
304
  *
305
305
  * @publicApi
306
306
  */
307
307
  export type Provider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider | ExistingProvider | FactoryProvider | any[];
308
+ /**
309
+ * Encapsulated `Provider`s that are only accepted during creation of an `EnvironmentInjector` (e.g.
310
+ * in an `NgModule`).
311
+ *
312
+ * Using this wrapper type prevents providers which are only designed to work in
313
+ * application/environment injectors from being accidentally included in
314
+ * `@Component.providers` and ending up in a component injector.
315
+ *
316
+ * This wrapper type prevents access to the `Provider`s inside.
317
+ *
318
+ * @see {@link makeEnvironmentProviders}
319
+ * @see {@link importProvidersFrom}
320
+ *
321
+ * @publicApi
322
+ */
323
+ export type EnvironmentProviders = {
324
+ ɵbrand: 'EnvironmentProviders';
325
+ };
326
+ export interface InternalEnvironmentProviders extends EnvironmentProviders {
327
+ ɵproviders: (Provider | EnvironmentProviders)[];
328
+ /**
329
+ * If present, indicates that the `EnvironmentProviders` were derived from NgModule providers.
330
+ *
331
+ * This is used to produce clearer error messages.
332
+ */
333
+ ɵfromNgModule?: true;
334
+ }
335
+ export declare function isEnvironmentProviders(value: Provider | EnvironmentProviders | InternalEnvironmentProviders): value is InternalEnvironmentProviders;
336
+ /**
337
+ * Describes a function that is used to process provider lists (such as provider
338
+ * overrides).
339
+ */
340
+ export type ProcessProvidersFunction = (providers: Provider[]) => Provider[];
341
+ /**
342
+ * A wrapper around an NgModule that associates it with [providers](guide/glossary#provider
343
+ * "Definition"). Usage without a generic type is deprecated.
344
+ *
345
+ * @see [Deprecations](guide/deprecations#modulewithproviders-type-without-a-generic)
346
+ *
347
+ * @publicApi
348
+ */
349
+ export interface ModuleWithProviders<T> {
350
+ ngModule: Type<T>;
351
+ providers?: Array<Provider | EnvironmentProviders>;
352
+ }
353
+ /**
354
+ * Providers that were imported from NgModules via the `importProvidersFrom` function.
355
+ *
356
+ * These providers are meant for use in an application injector (or other environment injectors) and
357
+ * should not be used in component injectors.
358
+ *
359
+ * This type cannot be directly implemented. It's returned from the `importProvidersFrom` function
360
+ * and serves to prevent the extracted NgModule providers from being used in the wrong contexts.
361
+ *
362
+ * @see {@link importProvidersFrom}
363
+ *
364
+ * @publicApi
365
+ * @deprecated replaced by `EnvironmentProviders`
366
+ */
367
+ export type ImportedNgModuleProviders = EnvironmentProviders;
@@ -111,8 +111,8 @@ export interface SelfDecorator {
111
111
  * <code-example path="core/di/ts/metadata_spec.ts" region="Self">
112
112
  * </code-example>
113
113
  *
114
- * @see `SkipSelf`
115
- * @see `Optional`
114
+ * @see {@link SkipSelf}
115
+ * @see {@link Optional}
116
116
  *
117
117
  */
118
118
  (): any;
@@ -153,8 +153,8 @@ export interface SkipSelfDecorator {
153
153
  * </code-example>
154
154
  *
155
155
  * @see [Dependency Injection guide](guide/dependency-injection-in-action#skip).
156
- * @see `Self`
157
- * @see `Optional`
156
+ * @see {@link Self}
157
+ * @see {@link Optional}
158
158
  *
159
159
  */
160
160
  (): any;
@@ -5,7 +5,7 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { Injector } from "./injector";
8
+ import { Injector } from './injector';
9
9
  export declare class NullInjector implements Injector {
10
10
  get(token: any, notFoundValue?: any): any;
11
11
  }
@@ -6,22 +6,64 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { Type } from '../interface/type';
9
- import { InjectorTypeWithProviders } from './interface/defs';
10
- import { ClassProvider, ConstructorProvider, ExistingProvider, FactoryProvider, StaticClassProvider, TypeProvider, ValueProvider } from './interface/provider';
9
+ import { ClassProvider, ConstructorProvider, EnvironmentProviders, ExistingProvider, FactoryProvider, ModuleWithProviders, Provider, StaticClassProvider, TypeProvider, ValueProvider } from './interface/provider';
11
10
  /**
12
- * Internal type for a single provider in a deep provider array.
11
+ * Wrap an array of `Provider`s into `EnvironmentProviders`, preventing them from being accidentally
12
+ * referenced in `@Component` in a component injector.
13
13
  */
14
- export type SingleProvider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider | ExistingProvider | FactoryProvider | StaticClassProvider;
14
+ export declare function makeEnvironmentProviders(providers: (Provider | EnvironmentProviders)[]): EnvironmentProviders;
15
15
  /**
16
- * The logic visits an `InjectorType`, an `InjectorTypeWithProviders`, or a standalone
17
- * `ComponentType`, and all of its transitive providers and collects providers.
16
+ * A source of providers for the `importProvidersFrom` function.
18
17
  *
19
- * If an `InjectorTypeWithProviders` that declares providers besides the type is specified,
20
- * the function will return "true" to indicate that the providers of the type definition need
21
- * to be processed. This allows us to process providers of injector types after all imports of
22
- * an injector definition are processed. (following View Engine semantics: see FW-1349)
18
+ * @publicApi
23
19
  */
24
- export declare function walkProviderTree(container: Type<unknown> | InjectorTypeWithProviders<unknown>, providersOut: SingleProvider[], parents: Type<unknown>[], dedup: Set<Type<unknown>>): container is InjectorTypeWithProviders<unknown>;
20
+ export type ImportProvidersSource = Type<unknown> | ModuleWithProviders<unknown> | Array<ImportProvidersSource>;
21
+ /**
22
+ * Collects providers from all NgModules and standalone components, including transitively imported
23
+ * ones.
24
+ *
25
+ * Providers extracted via `importProvidersFrom` are only usable in an application injector or
26
+ * another environment injector (such as a route injector). They should not be used in component
27
+ * providers.
28
+ *
29
+ * More information about standalone components can be found in [this
30
+ * guide](guide/standalone-components).
31
+ *
32
+ * @usageNotes
33
+ * The results of the `importProvidersFrom` call can be used in the `bootstrapApplication` call:
34
+ *
35
+ * ```typescript
36
+ * await bootstrapApplication(RootComponent, {
37
+ * providers: [
38
+ * importProvidersFrom(NgModuleOne, NgModuleTwo)
39
+ * ]
40
+ * });
41
+ * ```
42
+ *
43
+ * You can also use the `importProvidersFrom` results in the `providers` field of a route, when a
44
+ * standalone component is used:
45
+ *
46
+ * ```typescript
47
+ * export const ROUTES: Route[] = [
48
+ * {
49
+ * path: 'foo',
50
+ * providers: [
51
+ * importProvidersFrom(NgModuleOne, NgModuleTwo)
52
+ * ],
53
+ * component: YourStandaloneComponent
54
+ * }
55
+ * ];
56
+ * ```
57
+ *
58
+ * @returns Collected providers from the specified list of types.
59
+ * @publicApi
60
+ */
61
+ export declare function importProvidersFrom(...sources: ImportProvidersSource[]): EnvironmentProviders;
62
+ export declare function internalImportProvidersFrom(checkForStandaloneCmp: boolean, ...sources: ImportProvidersSource[]): Provider[];
63
+ /**
64
+ * Internal type for a single provider in a deep provider array.
65
+ */
66
+ export type SingleProvider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider | ExistingProvider | FactoryProvider | StaticClassProvider;
25
67
  export declare const USE_VALUE: string;
26
68
  export declare function isValueProvider(value: SingleProvider): value is ValueProvider;
27
69
  export declare function isExistingProvider(value: SingleProvider): value is ExistingProvider;
@@ -5,8 +5,8 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { AbstractType, Type } from "../interface/type";
9
- import { InjectionToken } from "./injection_token";
8
+ import { AbstractType, Type } from '../interface/type';
9
+ import { InjectionToken } from './injection_token';
10
10
  /**
11
11
  * @description
12
12
  *