-
Notifications
You must be signed in to change notification settings - Fork 26.3k
fix(language-service): resolve the variable from the template context first #35982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(language-service): resolve the variable from the template context first #35982
Conversation
eba8652
to
48d6c89
Compare
|
||
it('should not report error if template context conflict with component context', () => { | ||
mockHost.override(TEST_TEMPLATE, ` | ||
<div *ngFor="let h of heroes; let i = index"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a comment here to call out index
refers to the directive context and not the component context? Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's no need to add the test case for it. the index
only can refer to the directive context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should already be a test for this when checking the type of an ngFor export.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just add index
to the component context.
} | ||
// Try to resolve the variable from directive context first, then the component context. | ||
let symbol = getVariableTypeFromDirectiveContext(variable.value, info.query, current) || | ||
info.members.get(variable.value) || info.query.getBuiltinType(BuiltinType.Any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kyliau I think it's wrong to get the type of the variable from component context.
*ngIf="let a = b.c.d()"
the RHS of a let expression cannot be an expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the component context.
|
||
it('should not report error if template context conflict with component context', () => { | ||
mockHost.override(TEST_TEMPLATE, ` | ||
<div *ngFor="let h of heroes; let i = index"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should already be a test for this when checking the type of an ngFor export.
48d6c89
to
7112cb8
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
fixed: angular/vscode-ng-language-service#670
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information