I am going nuts currently why my typescript compilation (tsc) is always trying to compile node_modules files even when I've specified to exclude this folder.
[tl;dr; : it's because I have imports but I don't know how to exclude imports from compilation]
I'm using Visual Studio Code, but have the same issue when running tsc directly from commandline
My project structure is a typical one :
.
|
--node_modules\..
|
--src\..
|
--typings
In my root I have a tsconfig.json with following content:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"sourceMap": false,
"watch": false
},
"compileOnSave": true,
"exclude":
[
"node_modules"
]
}
But when I compile (using tsc directly in commandline or through visual studio code) I see a zillion of errors from \node_modules\angular..
Now, I do use import statements in my typescript files (because I want to use webpack in the end):
import * as angular from 'angular';
import router from 'angular-ui-router';
So, it seems the typescript compiler tries to import these angular modules AND compile...
I tried to use the --noResolve option in the tsconfig.json, but then my source files throw errors that they cannot find these modules..
I there any way I can tell the typescript compiler to not compile imported modules from folder xyz ?