我可以将 tsconfig 文件放在一个项目中,然后在另一个项目中使用它吗?
Can I put tsconfig file in one project and use it in another?
我的解决方案项目中有子模块。他们(第一个和第二个项目)都有 .ts 文件,所以我想把 tsconfig.json 放在子模块中并为他们两个共享。
在文件系统中它们的位置如下:
~/solution
--project1
--Scripts
--(ts files)
--submodule
--tsconfig.json(I want to put it here)
~/solution
--project2
--Scripts
--(ts files)
--submodule
project1's name is equal with project2's name
我尝试将 rootDir 添加到 compilerOptions
"rootDir": "..\project1\Scripts\**\*"
我尝试添加
"include": [
"..\project1\Scripts\**\*"
]
None 他们为我工作。
这是我的 tsconfig.json
{
"compileOnSave": true,
"buildOnSave": true,
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": true,
"sourceMap": false,
"target": "es5",
"module": "none",
"types": [],
"emitBOM": false,
"charset": "utf8"
},
"exclude": [
"node_modules",
"wwwroot"
]
}
如果你想在两个项目之间共享一个 tsconfig,你可以扩展一个 tsconfig.json
文件。例如,您有一个共享文件 shared.json
。
每个项目都有自己的 tsconfig.json
文件并扩展基础文件 shared.json
,像这样:
{
"extends": "../shared",
<options here that are different>
}
此页面的更多信息:
https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
我的解决方案项目中有子模块。他们(第一个和第二个项目)都有 .ts 文件,所以我想把 tsconfig.json 放在子模块中并为他们两个共享。
在文件系统中它们的位置如下:
~/solution
--project1
--Scripts
--(ts files)
--submodule
--tsconfig.json(I want to put it here)
~/solution
--project2
--Scripts
--(ts files)
--submodule
project1's name is equal with project2's name
我尝试将 rootDir 添加到 compilerOptions
"rootDir": "..\project1\Scripts\**\*"
我尝试添加
"include": [
"..\project1\Scripts\**\*"
]
None 他们为我工作。
这是我的 tsconfig.json
{
"compileOnSave": true,
"buildOnSave": true,
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": true,
"sourceMap": false,
"target": "es5",
"module": "none",
"types": [],
"emitBOM": false,
"charset": "utf8"
},
"exclude": [
"node_modules",
"wwwroot"
]
}
如果你想在两个项目之间共享一个 tsconfig,你可以扩展一个 tsconfig.json
文件。例如,您有一个共享文件 shared.json
。
每个项目都有自己的 tsconfig.json
文件并扩展基础文件 shared.json
,像这样:
{
"extends": "../shared",
<options here that are different>
}
此页面的更多信息: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html