Is there any way to tell vscode to not autoimport from specific files?
How to disable auto import from specific files in VSCode?
Asked Answered
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
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 excluded –
Thedathedric This doesn't work. –
Lientery
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.
This is the correct anwser. –
Unparliamentary
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
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 excluded –
Thedathedric This doesn't work. –
Lientery
© 2022 - 2024 — McMap. All rights reserved.