I have this setup of a TypeScript 2.0.3 project:
src/main/webapp/tsconfig.json
src/main/webapp/app -- contains .ts files
src/main/webapp/app/tsModels -- a symlink to ../../../../target/tsModels
target/tsModels/ -- contains .ts files
The goal is to get the .ts files in target/tsModels
compiled.
First, with "rootDir": "."
, tsc
complained:
error TS6059: File '[...]/target/tsModels/AboutWindupModel.ts' is not under 'rootDir' '[...]/src/main/webapp'. 'rootDir' is expected to contain all source files.
So I tried
{
"compilerOptions": { ...,
//"rootDir": ".",
"rootDirs": [".", "../../../target/tsModels"],
},
}
Still the same. Tried:
{
"compilerOptions": {
//"rootDir": ".",
"rootDirs": [".", "../../../target/tsModels"],
},
"exclude": [
"node_modules",
"target/**",
"../../../target/**",
"../../../target/**/*",
"../../../target/tsModels/*",
"typings/main",
"typings/main.d.ts"
]
}
But still getting that error.
So it seems that tsc
can't handle symlinks properly, always checks the canonical path.
So I thought, ok let's compile the tsModels
files directly. So I removed the symlink and tried:
"compilerOptions": {
//"rootDir": ".",
"rootDirs": [".", "../../../target/tsModels"],
},
But this doesn't actually compile the files in the tsModels
dir.
I have even tried
"rootDirs": "../../../target/tsModels",
but tsc
didn't compile that, instead, it compiled the .
. Does it obey that at all?
What should I do to compile files from both dirs?
Is there a way to use a symlink leading to dir outside rootDir
?
Full config with all the garbage I was trying:
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
//"rootDir": ".",
//"rootDirs": [".", "../../../target/tsModels"],
"rootDirs": ["../../../target/tsModels"],
//"rootDir": "../../../target/tsModels",
"outDir": "../../../target/windup-web",
"sourceRoot": "/windup-web/"
},
"exclude": [
"node_modules",
//"target/**",
//"../../../target/**",
//"../../../target/**/*",
//"../../../target/tsModels/*",
//"target/tsModels/**",
"typings/main",
"typings/main.d.ts"
]
}