diff --git a/packages/compiler/src/aot/static_reflector.ts b/packages/compiler/src/aot/static_reflector.ts index bb97bd1676..6af817f97b 100644 --- a/packages/compiler/src/aot/static_reflector.ts +++ b/packages/compiler/src/aot/static_reflector.ts @@ -601,7 +601,7 @@ export class StaticReflector implements ɵReflectorReader { case 'ignore': return expression; } - return null; + return IGNORE; } return mapStringMap(expression, (value, name) => simplify(value)); } diff --git a/packages/compiler/test/aot/static_reflector_spec.ts b/packages/compiler/test/aot/static_reflector_spec.ts index dd6fc683b3..9ea0ffda15 100644 --- a/packages/compiler/test/aot/static_reflector_spec.ts +++ b/packages/compiler/test/aot/static_reflector_spec.ts @@ -546,6 +546,30 @@ describe('StaticReflector', () => { expect(annotation.providers).toEqual([1, 2, 3, 4, 5, 6, 7]); }); + it('should ignore unresolved calls', () => { + const data = Object.create(DEFAULT_TEST_DATA); + const file = '/tmp/src/invalid-component.ts'; + data[file] = ` + import {Component} from '@angular/core'; + import {unknown} from 'unresolved'; + + @Component({ + selector: 'tmp', + template: () => {}, + providers: [triggers()] + }) + export class BadComponent { + + } + `; + init(data, [], () => {}, {verboseInvalidExpression: true}); + + const badComponent = reflector.getStaticSymbol(file, 'BadComponent'); + const annotations = reflector.annotations(badComponent); + const annotation = annotations[0]; + expect(annotation.providers).toEqual([]); + }); + describe('inheritance', () => { class ClassDecorator { constructor(public value: any) {} diff --git a/packages/compiler/test/aot/static_symbol_resolver_spec.ts b/packages/compiler/test/aot/static_symbol_resolver_spec.ts index 9adfc0ebdf..944d6c503c 100644 --- a/packages/compiler/test/aot/static_symbol_resolver_spec.ts +++ b/packages/compiler/test/aot/static_symbol_resolver_spec.ts @@ -436,6 +436,9 @@ export class MockStaticSymbolResolverHost implements StaticSymbolResolverHost { } return baseName + '.d.ts'; } + if (modulePath == 'unresolved') { + return undefined; + } return '/tmp/' + modulePath + '.d.ts'; }