Skip to content

[WIP] Fix auto-import ignoring barrel files with prefix names - #64031

Draft
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 1 commit into
mainfrom
copilot/fix-auto-import-barrel-ignore
Draft

[WIP] Fix auto-import ignoring barrel files with prefix names#64031
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 1 commit into
mainfrom
copilot/fix-auto-import-barrel-ignore

Conversation

Copilot AI commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.


This section details on the original issue you should resolve

<issue_title>Auto-import ignores barrel (index.ts) when the imported folder name is a prefix of the importing file name</issue_title>
<issue_description>### 🔎 Search Terms

auto-import index label:"Domain: LS: Auto-import"

🕗 Version & Regression Information

  • This changed between versions 6.0.3 and 7.0.2

VSCode version: 1.134.0
Windows 11

⏯ Playground Link

Example

💻 Code

Project structure example:

utils/
  sum/
    index.ts    // re‑exports sum from sum.ts
    sum.ts
  sumA/
    index.ts    // re‑exports sumA from sumA.ts
    sumA.ts
  sumABNums/
    index.ts    // re‑exports sumABNums from sumABNums.ts
    sumABNums.ts
  sumAB.ts      // importing file (the issue occurs here)
  index.ts      // importing file (works correctly)
// src/utils/sumAB.ts
import { sum } from "./sum/sum.js";
import { sumA } from "./sumA/sumA.js";
import { sumABNums } from "./sumABNums/index.js";

console.log(sum, sumA, sumABNums)

// src/utils/index.ts
import { sum } from "./sum/index.js";
import { sumA } from "./sumA/index.js";
import { sumABNums } from "./sumABNums/index.js";

console.log(sum, sumA, sumABNums)

🙁 Actual behavior

In utils/sumAB.ts:
for modules sum and sumA (whose folder names are prefixes of the importing file name sumAB.ts), the suggestion points to the direct file: './sum/sum.js' and './sumA/sumA.js'.
The barrel path './sum/index.js' and './sumA/index.js' is not offered.

For sumABNums (folder name is longer than the importing file name, so it is not a prefix), the correct barrel path './sumABNums/index.js' is suggested.

In utils/index.ts (also at the same level), imports for all modules correctly resolve via their barrel files.

🙂 Expected behavior

The barrel path ('./sum/index.js', './sumA/index.js') should always be the preferred suggestion when it exists, regardless of how the folder name relates to the importing file name.

Additional information about the issue

The issue seems to occur specifically when the imported folder name is a prefix of the importing file name. If the names differ by at least one character in a way that breaks the prefix relationship (e.g., sum and sumB or sam), the barrel path is correctly suggested.

In 6.0.3 barrel files are always ignored (in both files: utils/sumAB.ts and utils/index.ts).</issue_description>

Comments on the Issue (you are Copilot in this section)

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.

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

2 participants