Hello!
Currently, I am engaged in a small TypeScript project where I need to utilize two separate tsconfig.json
files, both of which inherit from my main tsconfig.base.json
file.
Unfortunately, I encountered an issue with the compiler creating unnecessary subfolders within the designated outDir
, causing me some frustration.
Presented below is the content of my core tsconfig.base.json
:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"resolveJsonModule": true,
"lib": ["es6", "dom"],
"esModuleInterop": true,
},
"exclude": [
"node_modules"
]
}
Additionally, here is a snippet from the derived tsconfig.src.json
:
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"rootDirs": ["./src/ts", "."],
"outDir": "./src/js/"
},
"exclude": [
"page/**/*.ts",
"tsconfig.page.json"
],
"include": [
"src/**/*.ts",
"service_account.json"
],
}
The current structure of my project appears as follows:
.
+-- node_modules/
+-- src/
| +-- js/ (desired compilation destination for TypeScript files)
| +-- ts/ (location of all TypeScript files)
+-- tsconfig.base.json
+-- tsconfig.src.json
+-- service_account.json
When executing the build:backend
script (
"build:backend": "tsc -p ./tsconfig.source.json"
), the compiler generates unwanted subfolders, resulting in the following project layout:
.
+-- node_modules/
+-- src/
| +-- js/
| +-- src/
| +-- ts/ (unexpected location of compiled JavaScript files now)
| +-- ts/
+-- tsconfig.base.json
+-- tsconfig.src.json
+-- service_account.json
If you have any insights on what could be causing this problem, your help would be greatly appreciated! Thank you in advance for your assistance!