diff --git a/packages/language-service/src/expression_diagnostics.ts b/packages/language-service/src/expression_diagnostics.ts index 39d5e3405cc..2d060ee894e 100644 --- a/packages/language-service/src/expression_diagnostics.ts +++ b/packages/language-service/src/expression_diagnostics.ts @@ -91,10 +91,8 @@ function getVarDeclarations( continue; } for (const variable of current.variables) { - let symbol = info.members.get(variable.value); - if (!symbol) { - symbol = getVariableTypeFromDirectiveContext(variable.value, info.query, current); - } + let symbol = getVariableTypeFromDirectiveContext(variable.value, info.query, current); + const kind = info.query.getTypeKind(symbol); if (kind === BuiltinType.Any || kind === BuiltinType.Unbound) { // For special cases such as ngFor and ngIf, the any type is not very useful. diff --git a/packages/language-service/test/project/app/parsing-cases.ts b/packages/language-service/test/project/app/parsing-cases.ts index 988aa6c5a45..e31f6a6e9b4 100644 --- a/packages/language-service/test/project/app/parsing-cases.ts +++ b/packages/language-service/test/project/app/parsing-cases.ts @@ -170,6 +170,8 @@ export class TemplateReference { primitiveIndexType: {[name: string]: string} = {}; anyValue: any; optional?: string; + // Use to test the `index` variable conflict between the `ngFor` and component context. + index = null; myClick(event: any) {} }