-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Description
Suggestion
🔍 Search Terms
autoImportFileExcludePatterns, exclude auto import suggestions
✅ Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
The option autoImportFileExcludePatterns currently works on the package/module (?) level. I can prevent a whole package from being suggested in auto-imports, but I can't exclude only some of the imports in certain subdirectories of that package. This was already mentioned as a caveat in the original implementation of the option (#49578 (comment)).
📃 Motivating Example
As in the comment mentioned above, my issue also comes from date-fns, but for a slightly different reason. The package has a locale module that includes exports for many different two-letter country codes. Those names also happen to conflict with variable names quite often. When typing one of the country codes, I get tons of suggestions from date-fns which appear before the one I actually want:
It's a minor annoyance, but I'd like to exclude those suggestions.
💻 Use Cases
Currently, I can add "**/node_modules/date-fns" or "date-fns" to the autoImportFileExcludePatterns option, which completely removes date-fns suggestions. But then I also lose the suggestions I actually want from the library.
I tried adding "date-fns/locale", "date-fns/locale/**", "date-fns/locale/*.*", but none of those work and result in no suggestions being excluded at all.
