Say I have a tsconfig.json file in a certain directory, and it looks like so:
{
"compilerOptions": {
"outDir": "./target",
"types": [
"node"
],
"typeRoots": [
"node_modules/@types"
],
"target": "es5",
"module": "commonjs",
"noImplicitAny": false,
"removeComments": true,
"preserveConstEnums": true,
"allowJs": false,
"allowUnreachableCode": true,
"lib": [
"es2015",
"es2016",
"es2017"
]
},
"exclude": [
"node_modules"
]
}
what this will do is transpile all .ts files below this tsconfig.json file, into a directory adjacent to the tsconfig.json file, but what if we want to transpile the files to a location relative to the source file, not relative to the tsconfig.json file.
Is there a way to do that?
In visual terms, we have this now:
test/
tsconfig.json
src/
foo1/
bar1.ts
foo2/
bar2.ts
target/
bar1.js
bar2.js
but I am looking for this instead:
test/
tsconfig.json
src/
foo1/
bar1.ts
target/
bar1.js
foo2/
bar2.ts
target/
bar2.js
As far as tsconfig.json, that might look like:
"outDir": "$(dirname ${sourceFile})/@target",