Reputation:
I have a typescript project with a hierarchy of files under the src
folder
src
+-components
| +-Thing.ts
| +-Widget.ts
+-libs
+-Utils.ts
I have typscript setup to generate output in the dist
folder so I get
dist
+-components
| +-Thing.d.ts
| +-Widget.d.ts
+-libs
+-Utils.d.ts
dist
is in my .gitignore
Often when VSCode auto inserts an import
statement it's often incorrectly inserting paths to dist
.
I type
const v: SomeClassInUtils
and it inserts
import { SomeClassInUtils } from "../../dist/lib/utils"
instead of
import { SomeClassInUtils } from "../lib/utils"
What configuration do I need to set to get VSCode to ignore dist
?
Upvotes: 2
Views: 2202
Reputation: 26404
You need to use autoImportFileExcludePatterns
with dist
:
"typescript.preferences.autoImportFileExcludePatterns": ["dist"]
If this doesn't work, try some variations of dist
like ./dist
, dist/*
, etc. before commenting.
You can either place this in your user settings (Ctrl + Shift + P > User Settings (JSON)) or create a file .vscode/settings.json
in the root folder of your project with this.
Upvotes: 6