Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f882ff0

Browse files
ivanwondermatsko
authored andcommitted
fix(language-service): resolve the variable from the template context first (#35982)
PR Close #35982
1 parent 2184ad5 commit f882ff0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

‎packages/language-service/src/expression_diagnostics.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,8 @@ function getVarDeclarations(
9191
continue;
9292
}
9393
for (const variable of current.variables) {
94-
let symbol = info.members.get(variable.value);
95-
if (!symbol) {
96-
symbol = getVariableTypeFromDirectiveContext(variable.value, info.query, current);
97-
}
94+
let symbol = getVariableTypeFromDirectiveContext(variable.value, info.query, current);
95+
9896
const kind = info.query.getTypeKind(symbol);
9997
if (kind === BuiltinType.Any || kind === BuiltinType.Unbound) {
10098
// For special cases such as ngFor and ngIf, the any type is not very useful.

‎packages/language-service/test/project/app/parsing-cases.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ export class TemplateReference {
170170
primitiveIndexType: {[name: string]: string} = {};
171171
anyValue: any;
172172
optional?: string;
173+
// Use to test the `index` variable conflict between the `ngFor` and component context.
174+
index = null;
173175
myClick(event: any) {}
174176
}
175177

0 commit comments

Comments
 (0)