diff --git a/packages/compiler/src/aot/static_symbol_resolver.ts b/packages/compiler/src/aot/static_symbol_resolver.ts index 62dd4de252..1861a28656 100644 --- a/packages/compiler/src/aot/static_symbol_resolver.ts +++ b/packages/compiler/src/aot/static_symbol_resolver.ts @@ -224,7 +224,7 @@ export class StaticSymbolResolver { this.recordImportAs(symbol, importSymbol); } - const origin = origins[metadataKey]; + const origin = origins.hasOwnProperty(metadataKey) && origins[metadataKey]; if (origin) { // If the symbol is from a bundled index, use the declaration location of the // symbol so relative references (such as './my.html') will be calculated diff --git a/packages/compiler/test/aot/compiler_spec.ts b/packages/compiler/test/aot/compiler_spec.ts index b72fe8d4da..51cd5aa39e 100644 --- a/packages/compiler/test/aot/compiler_spec.ts +++ b/packages/compiler/test/aot/compiler_spec.ts @@ -577,6 +577,7 @@ const FILES: MockData = { `, 'app.module.ts': ` import { NgModule } from '@angular/core'; + import { toString } from './utils'; import { AppComponent } from './app.component'; @@ -585,6 +586,12 @@ const FILES: MockData = { bootstrap: [ AppComponent ] }) export class AppModule { } + `, + // #15420 + 'utils.ts': ` + export function toString(value: any): string { + return ''; + } ` } }