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
This commit is contained in:
parent
2e47a0d19f
commit
ce47d33cd9
|
@ -601,7 +601,7 @@ export class StaticReflector implements ɵReflectorReader {
|
||||||
case 'ignore':
|
case 'ignore':
|
||||||
return expression;
|
return expression;
|
||||||
}
|
}
|
||||||
return null;
|
return IGNORE;
|
||||||
}
|
}
|
||||||
return mapStringMap(expression, (value, name) => simplify(value));
|
return mapStringMap(expression, (value, name) => simplify(value));
|
||||||
}
|
}
|
||||||
|
|
|
@ -546,6 +546,30 @@ describe('StaticReflector', () => {
|
||||||
expect(annotation.providers).toEqual([1, 2, 3, 4, 5, 6, 7]);
|
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', () => {
|
describe('inheritance', () => {
|
||||||
class ClassDecorator {
|
class ClassDecorator {
|
||||||
constructor(public value: any) {}
|
constructor(public value: any) {}
|
||||||
|
|
|
@ -436,6 +436,9 @@ export class MockStaticSymbolResolverHost implements StaticSymbolResolverHost {
|
||||||
}
|
}
|
||||||
return baseName + '.d.ts';
|
return baseName + '.d.ts';
|
||||||
}
|
}
|
||||||
|
if (modulePath == 'unresolved') {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return '/tmp/' + modulePath + '.d.ts';
|
return '/tmp/' + modulePath + '.d.ts';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue