refactor(ivy): pre-factor: set explicit type parameters for ModuleWithProviders (#25970)
Ivy depends on having the generic type token later when reading the ModuleWithProviders from a .d.ts file. PR Close #25970
This commit is contained in:
@ -75,16 +75,17 @@ export interface NgModuleDef<T, Declarations, Imports, Exports> {
|
||||
* @param T the module type. In Ivy applications, this must be explicitly
|
||||
* provided.
|
||||
*/
|
||||
export interface ModuleWithProviders<T = any> {
|
||||
export interface ModuleWithProviders<
|
||||
T = any /** TODO(alxhub): remove default when callers pass explicit type param */> {
|
||||
ngModule: Type<T>;
|
||||
providers?: Provider[];
|
||||
}
|
||||
|
||||
/**
|
||||
* A schema definition associated with an NgModule.
|
||||
*
|
||||
*
|
||||
* @see `@NgModule`, `CUSTOM_ELEMENTS_SCHEMA`, `NO_ERRORS_SCHEMA`
|
||||
*
|
||||
*
|
||||
* @param name The name of a defined schema.
|
||||
*
|
||||
* @experimental
|
||||
@ -135,7 +136,7 @@ export interface NgModule {
|
||||
/**
|
||||
* The set of injectable objects that are available in the injector
|
||||
* of this module.
|
||||
*
|
||||
*
|
||||
* @see [Dependency Injection guide](guide/dependency-injection)
|
||||
* @see [NgModule guide](guide/providers)
|
||||
*
|
||||
@ -145,14 +146,14 @@ export interface NgModule {
|
||||
* into any component, directive, pipe or service that is a child of this injector.
|
||||
* The NgModule used for bootstrapping uses the root injector, and can provide dependencies
|
||||
* to any part of the app.
|
||||
*
|
||||
*
|
||||
* A lazy-loaded module has its own injector, typically a child of the app root injector.
|
||||
* Lazy-loaded services are scoped to the lazy-loaded module's injector.
|
||||
* If a lazy-loaded module also provides the `UserService`, any component created
|
||||
* within that module's context (such as by router navigation) gets the local instance
|
||||
* of the service, not the instance in the root injector.
|
||||
* of the service, not the instance in the root injector.
|
||||
* Components in external modules continue to receive the instance provided by their injectors.
|
||||
*
|
||||
*
|
||||
* ### Example
|
||||
*
|
||||
* The following example defines a class that is injected in
|
||||
@ -236,7 +237,7 @@ export interface NgModule {
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
imports?: Array<Type<any>|ModuleWithProviders|any[]>;
|
||||
imports?: Array<Type<any>|ModuleWithProviders<{}>|any[]>;
|
||||
|
||||
/**
|
||||
* The set of components, directives, and pipes declared in this
|
||||
|
@ -228,7 +228,7 @@ function flatten<T>(values: any[]): T[] {
|
||||
return out;
|
||||
}
|
||||
|
||||
function expandModuleWithProviders(value: Type<any>| ModuleWithProviders): Type<any> {
|
||||
function expandModuleWithProviders(value: Type<any>| ModuleWithProviders<{}>): Type<any> {
|
||||
if (isModuleWithProviders(value)) {
|
||||
return value.ngModule;
|
||||
}
|
||||
@ -244,7 +244,7 @@ function wrapReference(value: Type<any>): R3Reference {
|
||||
return {value: wrapped, type: wrapped};
|
||||
}
|
||||
|
||||
function isModuleWithProviders(value: any): value is ModuleWithProviders {
|
||||
function isModuleWithProviders(value: any): value is ModuleWithProviders<{}> {
|
||||
return (value as{ngModule?: any}).ngModule !== undefined;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user