-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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): Do not include $event parameter in reference r… #40158
Conversation
…esults Given the template `<div (click)="doSomething($event)"></div>` If you request references for the `$event`, the results include both `$event` and `(click)="doSomething($event)"`. This happens because in the TCB, `$event` is passed to the `subscribe`/`addEventListener` function as an argument. So when we ask typescript to give us the references, we get the result from the usage in the subscribe body as well as the one passed in as an argument. This commit adds an identifier to the `$event` parameter in the TCB so that the result returned from `getReferencesAtPosition` can be identified and filtered out. fixes angular#40157
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.
👍
@@ -107,6 +107,22 @@ describe('find references', () => { | |||
assertTextSpans(refs, ['title']); | |||
}); | |||
|
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.
Suggestion
It gets a
$event
's reference to itself in a method call argument.
It's more helpful to maintainers to describe what the expected be behavior is, rather than say it should "work" :). What does "it works" mean.
Also, do you know if we have an official guide or code style on writing tests?
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.
Taking the above describe
, the full description of this test would read find references should work for $event in method call arguments
. Is that not descriptive enough?
No, there's no explicit style guide for tests.
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. |
…esults
Given the template
<div (click)="doSomething($event)"></div>
If you request references for the
$event
, the results include both$event
and(click)="doSomething($event)"
.This happens because in the TCB,
$event
is passed to thesubscribe
/addEventListener
function as an argument. So when we ask typescript to give us the references, we
get the result from the usage in the subscribe body as well as the one passed in as an argument.
This commit adds an identifier to the
$event
parameter in the TCB sothat the result returned from
getReferencesAtPosition
can beidentified and filtered out.
fixes #40157