Skip to content

Commit aa03cb9

Browse files
hawkgsmattrbeck
authored andcommitted
test(language-service): empty template literal interpolation
Ensure that empty template literal interpolation is handled gracefully. (cherry picked from commit 53ca8c2)
1 parent 5b516e3 commit aa03cb9

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎packages/language-service/test/diagnostic_spec.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,30 @@ describe('getSemanticDiagnostics', () => {
194194
);
195195
});
196196

197+
it('should report a parse error for an empty template literal interpolation', () => {
198+
const files = {
199+
'app.ts': `
200+
import {Component} from '@angular/core';
201+
202+
@Component({
203+
template: '<p>{{ \`Hello, $\{\}!\` }}</p>',
204+
})
205+
export class AppComponent {}
206+
`,
207+
};
208+
209+
const project = createModuleAndProjectWithDeclarations(env, 'test', files);
210+
const diags = project.getDiagnosticsForFile('app.ts');
211+
212+
expect(
213+
diags.some((diag) =>
214+
ts
215+
.flattenDiagnosticMessageText(diag.messageText, '')
216+
.includes('Parser Error: Template literal interpolation cannot be empty'),
217+
),
218+
).toBe(true);
219+
});
220+
197221
it('reports html parse errors along with typecheck errors as diagnostics', () => {
198222
const files = {
199223
'app.ts': `

0 commit comments

Comments
 (0)