forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler-cli): use correct module resolution context for absolute…
… imports in .d.ts files The compiler keeps track of how a declaration has been referenced using absolute module imports and from which path the absolute module should be resolved from. There was a bug in how the .d.ts metadata extraction would incorrectly use the .d.ts file itself as resolution context for symbols that had been imported using a relative module specifier. This could result in module resolution failures. For example, when extracting NgModule metadata from `/node_modules/lib/index.d.ts` that looks like ``` import {LibDirective} from './dir'; @NgModule({ declarations: [LibDirective], exports: [LibDirective], }) export class LibModule {} ``` and `/app.module.ts` that contains ``` import {LibModule} from 'lib'; @NgModule({ imports: [LibModule], }) export class AppModule {} ``` then `AppModule` would have recorded a reference to `LibModule` using the `'lib'` module specifier. When extracting the NgModule metadata from the `/node_modules/lib/index.d.ts` file the relative import into `./dir` should also be assumed to be importable from `'lib'` (according to APF where symbols need to be exported from a single entry-point) so the reference to `LibDirective` should have `'lib'` as absolute module specifier, but it would incorrectly have `/node_modules/lib/index.d.ts` as resolution context path. The latter is incorrect as `'lib'` needs to be resolved from `/app.module.ts` and not from within the library itself. Fixes angular#42810
- Loading branch information
Showing
4 changed files
with
111 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters