Skip to content

Conversation

@darwin808
Copy link

Summary

  • Fixes issue where import specifiers were not counted as references in code lens
  • For export function foo() and import { foo } from "./a", the import foo is now properly counted as a reference
  • Aligns behavior with TS 6.0

Changes

  • Added import specifiers to singleReferences in getSearchesFromDirectImports (importTracker.go)
  • Export specifiers are excluded since they're already handled by getReferencesAtExportSpecifier
  • Added deduplication in shouldAddSingleReference to prevent duplicate entries when traversing import/export chains
  • Updated duplicate detection logic in getReferencesAtLocation to handle simple import specifiers (not just import { foo as bar } patterns)

Test plan

  • All existing code lens tests pass with updated baselines
  • All findAllReferences tests pass with updated baselines
  • Verified foo now shows 4 references (was 3) in codeLensFunctionsAndConstants01 test

Fixes #2367

Previously, for `export function foo()` and `import { foo } from "./a"`,
the import specifier `foo` was not counted as a reference in the code lens.
This caused the reference count to be lower than expected (matching TS 5.x
behavior rather than TS 6.0 behavior).

This fix adds import specifiers to `singleReferences` in `getSearchesFromDirectImports`,
ensuring they are properly counted. Export specifiers are excluded since they are
already handled by `getReferencesAtExportSpecifier`.

Also added deduplication logic to prevent the same node from being added
multiple times when traversing import/export chains.

Fixes microsoft#2367
@darwin808
Copy link
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

References code lens does not include imports as references

1 participant