fix(language-service): Should not crash if expr ends unexpectedly (#33524)
If there is any parser errors when parsing template, we should stop
immediately and not proceed with template expression diagnostics.
This regression is caused by 6d11154652
and affected v9.0.0-next.4 onwards.
PR closes https://github.com/angular/vscode-ng-language-service/issues/436
PR Close #33524
This commit is contained in:
@ -56,6 +56,19 @@ describe('diagnostics', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('should report error for unexpected end of expression', () => {
|
||||
const content = mockHost.override(TEST_TEMPLATE, `{{ 5 / }}`);
|
||||
const diags = ngLS.getDiagnostics(TEST_TEMPLATE);
|
||||
expect(diags.length).toBe(1);
|
||||
const {messageText, start, length} = diags[0];
|
||||
expect(messageText)
|
||||
.toBe(
|
||||
'Parser Error: Unexpected end of expression: {{ 5 / }} ' +
|
||||
'at the end of the expression [{{ 5 / }}] in /app/test.ng@0:0');
|
||||
expect(start).toBe(0);
|
||||
expect(length).toBe(content.length);
|
||||
});
|
||||
|
||||
// https://github.com/angular/vscode-ng-language-service/issues/242
|
||||
it('should support $any() type cast function', () => {
|
||||
mockHost.override(TEST_TEMPLATE, `<div>{{$any(title).xyz}}</div>`);
|
||||
|
Reference in New Issue
Block a user