-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix find-all-refs for import("mod").Foo where Foo is a typedef #23881
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
Specifically, an |
src/services/utilities.ts
Outdated
@@ -179,6 +179,7 @@ namespace ts { | |||
|
|||
switch (node.parent.kind) { | |||
case SyntaxKind.TypeReference: | |||
case SyntaxKind.ImportType: |
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.
This should probably only be true if !(node.parent as ImportTypeNode).isTypeOf
, otherwise it acts like a type query instead.
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.
We do normally consider typeof
uses to be references though, e.g.:
const [|x|] = 0;
const y: typeof [|x|] = 0;
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.
Will the results still be classified correctly if that's picked up here and not where type queries are looked at?
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 actually isn't a specific place in find-all-references where we look for type queries -- we basically just look for identifiers with the same name and check for a symbol match.
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.
But this function is called from getMeaningFromLocation
so that means we need to handle this irrespectively to avoid any wrong usage being seeping out.
src/services/importTracker.ts
Outdated
break; | ||
|
||
default: | ||
Debug.assertNever(direct); |
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.
I'd include a helpful message here as the second parameter to assertNever
, just in case (if the types drift out of sync with reality because of an invalid cast, for example).
Fixes #23863
Needed to fix a few bugs:
ImportType
nodes -- added aDebug.assertNever
to prevent this from happening in the future.ImportType
should be considered a type reference.Discovered #23879 while working on this.