-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Improvements to find-all-references for import types #23998
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
317917f
to
926d8f5
Compare
926d8f5
to
c26c986
Compare
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 think I get most of it; just a few small comments.
if (reference.kind === "import") { | ||
const parent = reference.literal.parent; |
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.
Uhhhh, isn't reference.literal.parent
just reference
?
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.
reference
isn't a node, it's a ModuleReference
.
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.
Ahhhhh, ok
src/services/findAllReferences.ts
Outdated
return getReferencedSymbolsForModule(program, symbol, sourceFiles, sourceFilesSet); | ||
let moduleReferences: SymbolAndEntries[] = emptyArray; | ||
if (isModuleSymbol(symbol)) { | ||
const exportEquals = symbol.exports.get(InternalSymbolName.ExportEquals); |
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.
It's probably worth mentioning that JS is crazy and, I believe, can have both an export=
and non-export=
exports, via a file like
module.exports = class Foo {}
module.exports.a = "yes"
and I have no idea how that should behave with respect to find-all-refs. @sandersn knows our current behavior here, it's a bit in flux.
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.
Fixes #23879
Sequel to #23881
export =
we should get references to the exported thing too. So atconst x: import("[|foo|]")
we'll also get a reference toimport [|T|] = require("foo");
.export = [|T|]
in module "foo", get `import("[|foo|]") references.import("foo").[|T|]
no longer matchesexport type [|U|] = string;
.