Skip to content

Commit

Permalink
fix(compiler): ignore calls to unresolved symbols in metadata (angula…
Browse files Browse the repository at this point in the history
…r#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 angular#15969
  • Loading branch information
chuckjaz authored and Zhicheng Wang committed Aug 11, 2017
1 parent d5b5f1b commit 4d0725b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/compiler/src/aot/static_reflector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ export class StaticReflector implements ɵReflectorReader {
case 'ignore':
return expression;
}
return null;
return IGNORE;
}
return mapStringMap(expression, (value, name) => simplify(value));
}
Expand Down
24 changes: 24 additions & 0 deletions packages/compiler/test/aot/static_reflector_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
3 changes: 3 additions & 0 deletions packages/compiler/test/aot/static_symbol_resolver_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ export class MockStaticSymbolResolverHost implements StaticSymbolResolverHost {
}
return baseName + '.d.ts';
}
if (modulePath == 'unresolved') {
return undefined;
}
return '/tmp/' + modulePath + '.d.ts';
}

Expand Down

0 comments on commit 4d0725b

Please sign in to comment.