When performing diagnostic checks or completions, we should take into
account members and properties in the base class, if any. Otherwise, the
language service will produce a false error.
PR closes https://github.com/angular/vscode-ng-language-service/issues/93
PR Close #34041
(cherry picked from commit 7cd16b9e2c
)
PR Close #34046
This commit is contained in:

committed by
Matias Niemelä

parent
bbc8b0f142
commit
d22f3d6f85
@ -271,7 +271,11 @@ class TypeWrapper implements Symbol {
|
||||
}
|
||||
|
||||
members(): SymbolTable {
|
||||
return new SymbolTableWrapper(this.tsType.getProperties(), this.context);
|
||||
// Should call getApparentProperties() instead of getProperties() because
|
||||
// the former includes properties on the base class whereas the latter does
|
||||
// not. This provides properties like .bind(), .call(), .apply(), etc for
|
||||
// functions.
|
||||
return new SymbolTableWrapper(this.tsType.getApparentProperties(), this.context);
|
||||
}
|
||||
|
||||
signatures(): Signature[] { return signaturesOf(this.tsType, this.context); }
|
||||
|
@ -119,6 +119,14 @@ describe('diagnostics', () => {
|
||||
expect(diagnostics).toEqual([]);
|
||||
});
|
||||
|
||||
it('should not produce errors on function.bind()', () => {
|
||||
mockHost.override(TEST_TEMPLATE, `
|
||||
<test-comp (test)="myClick.bind(this)">
|
||||
</test-comp>`);
|
||||
const diags = ngLS.getDiagnostics(TEST_TEMPLATE);
|
||||
expect(diags).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