Skip to content

Commit ce47d33

Browse files
chuckjaztbosch
authored andcommitted
fix(compiler): ignore calls to unresolved symbols in metadata (#15970)
This only shows up in the language service. Calls to symbols that are not resolve resulted in null instead of being resolved causing the language service to see exceptions when the null was not expected such as in the animations array. Fixes #15969
1 parent 2e47a0d commit ce47d33

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

packages/compiler/src/aot/static_reflector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ export class StaticReflector implements ɵReflectorReader {
601601
case 'ignore':
602602
return expression;
603603
}
604-
return null;
604+
return IGNORE;
605605
}
606606
return mapStringMap(expression, (value, name) => simplify(value));
607607
}

packages/compiler/test/aot/static_reflector_spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,30 @@ describe('StaticReflector', () => {
546546
expect(annotation.providers).toEqual([1, 2, 3, 4, 5, 6, 7]);
547547
});
548548

549+
it('should ignore unresolved calls', () => {
550+
const data = Object.create(DEFAULT_TEST_DATA);
551+
const file = '/tmp/src/invalid-component.ts';
552+
data[file] = `
553+
import {Component} from '@angular/core';
554+
import {unknown} from 'unresolved';
555+
556+
@Component({
557+
selector: 'tmp',
558+
template: () => {},
559+
providers: [triggers()]
560+
})
561+
export class BadComponent {
562+
563+
}
564+
`;
565+
init(data, [], () => {}, {verboseInvalidExpression: true});
566+
567+
const badComponent = reflector.getStaticSymbol(file, 'BadComponent');
568+
const annotations = reflector.annotations(badComponent);
569+
const annotation = annotations[0];
570+
expect(annotation.providers).toEqual([]);
571+
});
572+
549573
describe('inheritance', () => {
550574
class ClassDecorator {
551575
constructor(public value: any) {}

packages/compiler/test/aot/static_symbol_resolver_spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,9 @@ export class MockStaticSymbolResolverHost implements StaticSymbolResolverHost {
436436
}
437437
return baseName + '.d.ts';
438438
}
439+
if (modulePath == 'unresolved') {
440+
return undefined;
441+
}
439442
return '/tmp/' + modulePath + '.d.ts';
440443
}
441444

0 commit comments

Comments
 (0)