fix(language-service): Function alias should be callable (#33782)
This commit fixes a long standing bug whereby a template variable that gets initialized to a class method gets resolved to the Any type, thus when it is called the language service produces error "Member X is not callable". PR closes https://github.com/angular/angular/issues/16643 PR closes https://github.com/angular/vscode-ng-language-service/issues/234 PR Close #33782
This commit is contained in:

committed by
Alex Rickabaugh

parent
ab0bcee144
commit
1d3aae6f92
@ -109,6 +109,16 @@ describe('diagnostics', () => {
|
||||
.toBe(`Identifier 'age' is not defined. 'Hero' does not contain such a member`);
|
||||
});
|
||||
|
||||
it('should not report error for variable initialized as class method', () => {
|
||||
mockHost.override(TEST_TEMPLATE, `
|
||||
<ng-template let-greet="myClick">
|
||||
<span (click)="greet()"></span>
|
||||
</ng-template>
|
||||
`);
|
||||
const diagnostics = ngLS.getDiagnostics(TEST_TEMPLATE);
|
||||
expect(diagnostics).toEqual([]);
|
||||
});
|
||||
|
||||
describe('in expression-cases.ts', () => {
|
||||
it('should report access to an unknown field', () => {
|
||||
const diags = ngLS.getDiagnostics(EXPRESSION_CASES).map(d => d.messageText);
|
||||
|
Reference in New Issue
Block a user