Open mjbvz opened 4 years ago
This seems tricky. Obviously you can write something like:
const a: Foo = new SubFoo();
a.bar();
Which would call SubFoo.bar
at runtime, yet should probably count as a reference to Foo.bar
?
Moving this issue upstream for more feedback
I'm pretty strongly in the camp that that this behavior is correct, but I guess I'm willing to hear more if there's a compelling justification.
I'm pretty strongly in the camp that that this behavior is correct, but I guess I'm willing to hear more if there's a compelling justification.
I think that the original report example is pretty compelling
The references code lens is implemented with find all references
so it's the same problem:
const x: Array = new X()
x.filter(); // Should this be counted as a reference to `X.filter`?
Since this issue is now a discussion, I would like to say that I agree with @mjbvz.
Here's an example to justify:
In a typescript NestJS project, there are many services. Each service is a class.
Let's say you have a class BaseService
that implements some common logic, which you can override if needed.
I have ServiceX
which extends BaseService
and overrides one of the methods there.
I wish to find all the references of to the overridden method in ServiceX
. With current behavior, I will simply get a list of all the places that reference the function of all the derived classes - which might be a huge list of references. While all I want is just a very small subset.
https://github.com/microsoft/vscode/issues/93654
TypeScript Version: 3.9.0-dev.20200409
Search Terms:
Code For the TS
find all references
onbar
inclass SubFoo
Expected behavior: A reference to
new SubFoo().bar();
is returnedActual behavior: Two references are returned, including one to the parent class's
bar