How to disable auto import from specific files in VSCode?
Asked Answered
R

2

22

Is there any way to tell vscode to not autoimport from specific files?

Rillings answered 13/12, 2017 at 15:19 Comment(0)
C
9

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

Chitin answered 13/12, 2017 at 18:48 Comment(5)
Have you got a source for this? I can not reliably exclude using this technique.Thedathedric
Do you have a jsconfig or tsconfig?Chitin
I have a tsconfig.Thedathedric
See this repo: 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 excludedThedathedric
This doesn't work.Lientery
Z
10

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.

enter image description here

Zinkenite answered 18/11, 2022 at 8:17 Comment(1)
This is the correct anwser.Unparliamentary
C
9

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

Chitin answered 13/12, 2017 at 18:48 Comment(5)
Have you got a source for this? I can not reliably exclude using this technique.Thedathedric
Do you have a jsconfig or tsconfig?Chitin
I have a tsconfig.Thedathedric
See this repo: 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 excludedThedathedric
This doesn't work.Lientery

© 2022 - 2024 — McMap. All rights reserved.