fix(tsc-wrapped): report errors for invalid ast forms (#17994)
Fixes: #17993
This commit is contained in:
parent
4f1e4ffa4e
commit
ce0f4f0d7c
@ -388,6 +388,9 @@ export class Evaluator {
|
|||||||
if (isFoldableError(expression)) {
|
if (isFoldableError(expression)) {
|
||||||
return recordEntry(expression, node);
|
return recordEntry(expression, node);
|
||||||
}
|
}
|
||||||
|
if (!elementAccessExpression.argumentExpression) {
|
||||||
|
return recordEntry(errorSymbol('Expression form not supported', node), node);
|
||||||
|
}
|
||||||
const index = this.evaluateNode(elementAccessExpression.argumentExpression);
|
const index = this.evaluateNode(elementAccessExpression.argumentExpression);
|
||||||
if (isFoldableError(expression)) {
|
if (isFoldableError(expression)) {
|
||||||
return recordEntry(expression, node);
|
return recordEntry(expression, node);
|
||||||
|
@ -864,6 +864,28 @@ describe('Collector', () => {
|
|||||||
const metadata = collector.getMetadata(source);
|
const metadata = collector.getMetadata(source);
|
||||||
expect(metadata).toBeUndefined();
|
expect(metadata).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should be able to collect an invalid access expression', () => {
|
||||||
|
const source = createSource(`
|
||||||
|
import {Component} from '@angular/core';
|
||||||
|
|
||||||
|
const value = [];
|
||||||
|
@Component({
|
||||||
|
provider: [{provide: 'some token', useValue: value[]}]
|
||||||
|
})
|
||||||
|
export class MyComponent {}
|
||||||
|
`);
|
||||||
|
const metadata = collector.getMetadata(source);
|
||||||
|
expect(metadata.metadata.MyComponent).toEqual({
|
||||||
|
__symbolic: 'class',
|
||||||
|
decorators: [{
|
||||||
|
__symbolic: 'error',
|
||||||
|
message: 'Expression form not supported',
|
||||||
|
line: 5,
|
||||||
|
character: 55
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function override(fileName: string, content: string) {
|
function override(fileName: string, content: string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user