fix(language-service): resolve the variable from the template context first (#35982)

PR Close #35982
This commit is contained in:
ivanwonder 2020-03-10 12:22:46 +08:00 committed by Matias Niemelä
parent 406419bc0f
commit 3d46a45fa8
2 changed files with 4 additions and 4 deletions

View File

@ -91,10 +91,8 @@ function getVarDeclarations(
continue; continue;
} }
for (const variable of current.variables) { for (const variable of current.variables) {
let symbol = info.members.get(variable.value); let symbol = getVariableTypeFromDirectiveContext(variable.value, info.query, current);
if (!symbol) {
symbol = getVariableTypeFromDirectiveContext(variable.value, info.query, current);
}
const kind = info.query.getTypeKind(symbol); const kind = info.query.getTypeKind(symbol);
if (kind === BuiltinType.Any || kind === BuiltinType.Unbound) { if (kind === BuiltinType.Any || kind === BuiltinType.Unbound) {
// For special cases such as ngFor and ngIf, the any type is not very useful. // For special cases such as ngFor and ngIf, the any type is not very useful.

View File

@ -170,6 +170,8 @@ export class TemplateReference {
primitiveIndexType: {[name: string]: string} = {}; primitiveIndexType: {[name: string]: string} = {};
anyValue: any; anyValue: any;
optional?: string; optional?: string;
// Use to test the `index` variable conflict between the `ngFor` and component context.
index = null;
myClick(event: any) {} myClick(event: any) {}
birthday = new Date(); birthday = new Date();
} }