fix(compiler-cli): attach the correct viaModule
to namespace imports (#33495)
Previously declarations that were imported via a namespace import were given the same `bestGuessOwningModule` as the context where they were imported to. This causes problems with resolving `ModuleWithProviders` that have a type that has been imported in this way, causing errors like: ``` ERROR in Symbol UIRouterModule declared in .../@uirouter/angular/uiRouterNgModule.d.ts is not exported from .../@uirouter/angular/uirouter-angular.d.ts (import into .../src/app/child.module.ts) ``` This commit modifies the `TypescriptReflectionHost.getDirectImportOfIdentifier()` method so that it also understands how to attach the correct `viaModule` to the identifier of the namespace import. Resolves #32166 PR Close #33495
This commit is contained in:

committed by
atscott

parent
d5ae854b5b
commit
1d141a8ab1
@ -1558,7 +1558,7 @@ runInEachFileSystem(() => {
|
||||
const actualDeclaration = host.getDeclarationOfIdentifier(identifier);
|
||||
expect(actualDeclaration).not.toBe(null);
|
||||
expect(actualDeclaration !.node).toBe(expectedDeclarationNode);
|
||||
expect(actualDeclaration !.viaModule).toBe(null);
|
||||
expect(actualDeclaration !.viaModule).toBe('@angular/core');
|
||||
});
|
||||
|
||||
it('should return the original declaration of an aliased class', () => {
|
||||
|
@ -1788,7 +1788,7 @@ runInEachFileSystem(() => {
|
||||
const actualDeclaration = host.getDeclarationOfIdentifier(identifier);
|
||||
expect(actualDeclaration).not.toBe(null);
|
||||
expect(actualDeclaration !.node).toBe(expectedDeclarationNode);
|
||||
expect(actualDeclaration !.viaModule).toBe(null);
|
||||
expect(actualDeclaration !.viaModule).toBe('@angular/core');
|
||||
});
|
||||
|
||||
it('should return the correct declaration for an inner function identifier inside an ES5 IIFE',
|
||||
|
Reference in New Issue
Block a user