Description
Search Terms
autoimport, exclude, ignore, isolation, encapsulation
Suggestion
We need a way to exclude files from auto import. Not from the project, only from the auto import suggestions.
Use Cases
My project includes a .d.ts file (generated from the previous version of the project) with legacy data structures (interfaces), many of which have the same names as their counterparts, newer data structures. As that file uses declare module "..." { ... }
syntax, imports from it are non-relative, which is why auto import gives them a higher priority whereas modules with the newer structures have relative paths. The result is that the 'Add all missing imports' command constantly creates lots of wrong imports. If only there were a way to suppress suggestions for that specific module. I want to import from it only in rare cases.
I feel like this problem kind of defeats one of the important points of modules: I wanted to isolate those legacy definitions inside their module and forget about them, but because of this auto import issue they constantly get in the way.
Another example. Type definitions for libraries are in no hurry to use the new asserts
feature of TS 3.7 for compatibility reasons. When I defined my own assert
function to benefit from this feature, VS Code started to insist on importing assert
form Node's console
module instead, so, for lack of a better solution, I ended up renaming the function.
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, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.