Skip to content

Fix auto-import barrel ranking for path-prefix collisions - #64107

Merged
Andrew Branch (andrewbranch) merged 2 commits into
mainfrom
copilot/fix-auto-import-ignores-barrel
Aug 31, 2026
Merged

Fix auto-import barrel ranking for path-prefix collisions#64107
Andrew Branch (andrewbranch) merged 2 commits into
mainfrom
copilot/fix-auto-import-ignores-barrel

Conversation

Copilot AI commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Auto-import incorrectly penalized an index barrel when its directory name was a textual prefix of the importing file name:

/utils/sum/index.ts
/utils/sumAB.ts
  • Root cause: Circular-import detection used a plain string-prefix check, treating sumAB.ts as contained by sum/.
  • Change: Require a path-segment boundary when checking directory containment.
  • Coverage: Add a NodeNext fourslash regression test verifying both barrel and direct ESM import paths are offered in the correct order.

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix auto-import behavior with barrel files and prefix names Fix auto-import barrel ranking for path-prefix collisions Aug 31, 2026
@andrewbranch
Andrew Branch (andrewbranch) marked this pull request as ready for review August 31, 2026 16:30
Copilot AI balanced review requested due to automatic review settings August 31, 2026 16:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes auto-import barrel ranking when a directory name prefixes the importing filename.

Changes:

  • Requires a directory boundary in the cycle heuristic.
  • Adds NodeNext ESM regression coverage for ordering.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tsc/internal/ls/autoimport/fix.go Corrects directory containment detection.
tsc/internal/fourslash/tests/autoImportIndexReExportPrefix_test.go Verifies barrel and direct import ordering.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Aug 31, 2026
Merged via the queue into main with commit f609ef1 Aug 31, 2026
27 checks passed
@andrewbranch
Andrew Branch (andrewbranch) deleted the copilot/fix-auto-import-ignores-barrel branch August 31, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-import ignores barrel (index.ts) when the imported folder name is a prefix of the importing file name

4 participants