fix(ivy): properly compile NgModules with forward referenced types (#29198)
Previously, ngtsc would resolve forward references while evaluating the bootstrap, declaration, imports, and exports fields of NgModule types. However, when generating the resulting ngModuleDef, the forward nature of these references was not taken into consideration, and so the generated JS code would incorrectly reference types not yet declared. This commit fixes this issue by introducing function closures in the NgModuleDef type, similarly to how NgComponentDef uses them for forward declarations of its directives and pipes arrays. ngtsc will then generate closures when required, and the runtime will unwrap them if present. PR Close #29198
This commit is contained in:

committed by
Kara Erickson

parent
1625d86178
commit
73da2792c9
@ -49,19 +49,19 @@ export interface NgModuleDef<T> {
|
||||
type: T;
|
||||
|
||||
/** List of components to bootstrap. */
|
||||
bootstrap: Type<any>[];
|
||||
bootstrap: Type<any>[]|(() => Type<any>[]);
|
||||
|
||||
/** List of components, directives, and pipes declared by this module. */
|
||||
declarations: Type<any>[];
|
||||
declarations: Type<any>[]|(() => Type<any>[]);
|
||||
|
||||
/** List of modules or `ModuleWithProviders` imported by this module. */
|
||||
imports: Type<any>[];
|
||||
imports: Type<any>[]|(() => Type<any>[]);
|
||||
|
||||
/**
|
||||
* List of modules, `ModuleWithProviders`, components, directives, or pipes exported by this
|
||||
* module.
|
||||
*/
|
||||
exports: Type<any>[];
|
||||
exports: Type<any>[]|(() => Type<any>[]);
|
||||
|
||||
/**
|
||||
* Cached value of computed `transitiveCompileScopes` for this module.
|
||||
|
Reference in New Issue
Block a user