feat(language-service): warn when a method isn't called in an event (#13437)

Closes 13435
This commit is contained in:
Chuck Jazdzewski
2016-12-13 11:20:45 -08:00
committed by Victor Berchet
parent 4b3d135193
commit 9ec0a4e105
3 changed files with 33 additions and 13 deletions

View File

@ -130,6 +130,17 @@ describe('diagnostics', () => {
});
});
it('should report a warning if an event results in a callable expression', () => {
const code =
` @Component({template: \`<div (click)="onClick"></div>\`}) export class MyComponent { onClick() { } }`;
addCode(code, (fileName, content) => {
const diagnostics = ngService.getDiagnostics(fileName);
includeDiagnostic(
diagnostics, 'Unexpected callable expression. Expected a method call', 'onClick',
content);
});
});
function addCode(code: string, cb: (fileName: string, content?: string) => void) {
const fileName = '/app/app.component.ts';
const originalContent = mockHost.getFileContent(fileName);