feat(ivy): give ngtsc a basic understanding of ModuleWithProviders (#24738)
This commit changes the @NgModule provider to understand that sometimes an import will resolve to an object instead of a type, and that object could be of the ModuleWithProviders type. In that case, the 'ngModule' property is read, and its value used instead. This still will not handle ModuleWithProviders references across compilation units; that work is coming in a future PR. PR Close #24738
This commit is contained in:
parent
a1b630ee8f
commit
9f20dd937a
|
@ -132,6 +132,12 @@ function resolveTypeList(resolvedList: ResolvedValue, name: string): Reference[]
|
||||||
}
|
}
|
||||||
|
|
||||||
resolvedList.forEach((entry, idx) => {
|
resolvedList.forEach((entry, idx) => {
|
||||||
|
// Unwrap ModuleWithProviders for modules that are locally declared (and thus static resolution
|
||||||
|
// was able to descend into the function and return an object literal, a Map).
|
||||||
|
if (entry instanceof Map && entry.has('ngModule')) {
|
||||||
|
entry = entry.get('ngModule') !;
|
||||||
|
}
|
||||||
|
|
||||||
if (Array.isArray(entry)) {
|
if (Array.isArray(entry)) {
|
||||||
// Recurse into nested arrays.
|
// Recurse into nested arrays.
|
||||||
refList.push(...resolveTypeList(entry, name));
|
refList.push(...resolveTypeList(entry, name));
|
||||||
|
@ -144,7 +150,7 @@ function resolveTypeList(resolvedList: ResolvedValue, name: string): Reference[]
|
||||||
refList.push(entry);
|
refList.push(entry);
|
||||||
} else {
|
} else {
|
||||||
// TODO(alxhub): expand ModuleWithProviders.
|
// TODO(alxhub): expand ModuleWithProviders.
|
||||||
throw new Error(`Value at position ${idx} in ${name} array is not a reference`);
|
throw new Error(`Value at position ${idx} in ${name} array is not a reference: ${entry}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue