Is there any way to tell vscode to not autoimport from specific files?
Asked
Active
Viewed 6,226 times
2 Answers
10
No. VS Code will pick up auto imports from all files in your jsconfig
or tsconfig
project.
If the file should not be part of your project, you can exclude it using the excludes
or includes
/ files
configuration option in the jsconfig or tsconfig

Matt Bierner
- 58,117
- 21
- 175
- 206
-
3Have you got a source for this? I can not reliably exclude using this technique. – dwjohnston Nov 26 '20 at 02:15
-
1Do you have a jsconfig or tsconfig? – Matt Bierner Nov 26 '20 at 06:04
-
I have a tsconfig. – dwjohnston Nov 26 '20 at 06:09
-
See this repo: https://github.com/dwjohnston/import-from-parent-issue/tree/tsconfig (note tsconfig branch) go to `src/foo/fooFile.ts` and note that it still wants to import from the `src/index.ts` file, even though that it is excluded – dwjohnston Nov 26 '20 at 06:13
-
8This doesn't work. – Chrillewoodz Dec 07 '21 at 07:53
4
VSCode now supports this natively, if your project uses TypeScript 4.8+.
Just search for "auto import" in your settings menu, or use the typescript.preferences.autoImportFileExcludePatterns
key in your json.

panepeter
- 3,224
- 1
- 29
- 41