-
Notifications
You must be signed in to change notification settings - Fork 13k
Fixed find all references for private identifiers. #35887
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
Conversation
Thanks so much for fixing this! I think it would be nice to have a fourslash test for this, similar to the go-to-definition tests. |
@mheiber wops forgot to commit the file (fourslash tests is the way I tested it first 😊), fixed now. Also missed the |
3471079
to
e617035
Compare
Holy crap that was fast. @typescript-bot pack this |
Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at e617035. You can monitor the build here. It should now contribute to this PR's status checks. |
Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
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.
For some reason, find-all-refs at the end of the private name is failing.
class C {
#foo/*findAllRefs1*/: string;
blah() {
this.#foo/*findAllRefs2*/;
}
}
e617035
to
f1e86c2
Compare
@DanielRosenwasser Fixed. Figuring out how to write the fourslash test.. 30 min.. figuring out the bug 10 min ... 😅 I fear there will be a lot more bugs relating to |
@dragomirtitian , re
I agree it's hard to catch all the cases where private identifiers need to be considered. If you have ideas for how to refactor so that the type system can help catch more of these cases, I'd be interested in trying the ideas out. |
@@ -0,0 +1,24 @@ | |||
/// <reference path='fourslash.ts'/> |
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.
The "privateProperties" in the test name may be confusing, given that we have private
modifier and ES private fields (#
).
Other ES private field tests have privateName
in the name. I propose using privateName
here for consistency, and perhaps a future PR to change the tests to esPrivate
or hashPrivate
or privateIdentifier
or whatever works best.
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.
Was not aware of the convention. Renamed the test file.
Re Daniel's comment:
fwiw, I built the lang server from this PR locally and did some manual testing. I'm seeing public and private fields behave the same way when I right-click the end of a name in VS Code. Building on Daniel's example: export default 3;
class C {
#foo: string;
bar: number;
blah() {
this.#foo/*loc1*/;
this.bar/*loc2*/;
}
}
|
@mheiber Your last comment is not clear to me. Is there something that does not work in the current PR? Daniel reported the bug previously, but I since fixed it (I amended the original commit so you can't really see the fix separately, it was caused my a missing |
f1e86c2
to
7122566
Compare
I am unsure why the tests CI/build fails for node12. I tried running |
3 failing tests due to timeouts. Seems spurious to me, fwiw:
|
7122566
to
ace8822
Compare
@typescript-bot pack this |
Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at ace8822. You can monitor the build here. It should now contribute to this PR's status checks. |
Just as a heads up, I think you implemented the test correctly (especially since you want to make sure that private names from other classes don't get picked up), but in the future, I believe there are other helpers to make sure that all ranges in the test provide the same results to find-all-references. |
Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
cc: @mheiber
Fixes #35883