【发布时间】:2020-08-23 23:20:55
【问题描述】:
你好!
我正在使用 TypeScript 进行一个小项目,这需要我有两个不同的 tsconfig.json 文件,它们都继承自我的 tsconfig.base.json 文件。
我遇到了编译器在我声明的 outDir 中创建子文件夹的问题,这让我发疯了。
这是我的tsconfig.base.json 文件:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"resolveJsonModule": true,
"lib": ["es6", "dom"],
"esModuleInterop": true,
},
"exclude": [
"node_modules"
]
}
这就是派生的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"
],
}
我目前的项目结构是这样的:
.
+-- node_modules/
+-- src/
| +-- js/ (this is where my typescript files should be compiled to)
| +-- ts/ (this is where all my ts files are located)
+-- tsconfig.base.json
+-- tsconfig.src.json
+-- service_account.json
现在,如果我运行我的 build:backend 脚本 ("build:backend": "tsc -p ./tsconfig.source.json"),编译器会创建两个子文件夹,这会使我的项目结构如下所示:
.
+-- node_modules/
+-- src/
| +-- js/ (this is where my typescript files should be compiled to)
| +-- src/
| +-- ts/ (here are all compiled js files now)
| +-- ts/ (this is where all my ts files are located)
+-- tsconfig.base.json
+-- tsconfig.src.json
+-- service_account.json
有人知道是什么导致了这个问题吗?
感谢您的各种帮助!提前谢谢各位!
【问题讨论】:
标签: json typescript tsc tsconfig