Reputation: 85
I have a tsconfig.json file with the following:
{"compilerOptions": {
"module": "commonjs",
"noImplicitAny": false,
"removeComments": true,
"preserveConstEnums": true,
"outDir": "./target/src/",
"rootDir": "./src/main/webapp/",
"sourceMap": true,
"experimentalDecorators": true
},
"exclude": ["node_modules", "target"]
}
When I run tsc I get the error:
error TS6059: File '../node_modules/ng2-select/components/ng2-select-config.ts' is not under 'rootDir' 'main/webapp'. 'rootDir' is expected to contain all source files.
The culprit seems to be when I try to load ng2-select in a file:
import {Component} from 'angular2/core';
import {select} from 'ng2-select';
If I run tsc without the second import it's fine. If I add the second I get that error.
Any ideas as to why it's trying to compile ng2-select even though it's supposed to be ignored?
Thanks!
Upvotes: 2
Views: 2380
Reputation: 136
This is either an issue with the structure of the ng2-select
module or a bug with the typescript compiler.
The issue is caused by having .ts
and .d.ts
files in the same directory as each other within the module directory that you are trying to load from. This seems to cause the typescript compiler to recompile the module then getting confused because it compiled something outside of the rootDir
.
I have had the same issue and have raised it on the module's GitHub repository. This answer may help you for now though it isn't ideal. Hopefully there'll be a fix soon.
Update
The latest release fixes this issue.
Upvotes: 1