Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop VS Code from suggesting I import code from my transpiled files?

I think I have a reasonably common project setup. A src directory that contains all my TypeScript code and a dist directory which contains the compiles JavaScript. The problem is when I enter a symbol from a different module into my code and VS Code suggests places to import it from it will show both the TypeScript module and the compiled module as options. Often the compiled one shows up first in the list and so I frequently accidentally import from my compiled code.

I've ended up putting a lint rule in place to show an error when I do this but I'd much prefer it if I could tell VS Code to ignore the dist directory for the purposes of suggesting modules to import. Is there a way to do this?

like image 477
Dave Townsend Avatar asked Nov 07 '22 04:11

Dave Townsend


1 Answers

Adding "exclude" option to your "tsconfig.json" file should fix this issue.

{
  "compilerOptions": {
    /* Basic Options */
    "target": "es5",
    "module": "commonjs",
    "strict": true,
     
    "outDir": "./dist"
},
  "exclude": [
    "./dist/"
  ]
}
like image 109
Nikhil Shekhar Avatar answered Nov 14 '22 21:11

Nikhil Shekhar