typescript - 我可以将 tsconfig 文件放在一个项目中并在另一个项目中使用它吗?
问题描述
我的解决方案项目中有子模块。他们两个(第一个第二个项目)都有 .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\\**\\*"
]
它们都不适合我。
这是我的 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
推荐阅读
- hyperledger-fabric - 如何将我们自己在 node.js 中编写的链代码放置在超级账本结构中
- ruby-on-rails - 从两个数据源创建哈希的最优雅方式
- macos - Mac/Linux 命令:从任何地方访问?
- javascript - 正则表达式允许中文或字母字符
- java - 如何编写 Do/While 验证?
- c - 与 OpenGL ES 渲染和 windows 多线程冲突
- angular - 删除方法中的 HTTP 错误无法正常工作
- c# - Asp Net Core MVC Identity Dapper 获取所有用户
- sql - 在sql中将varchar转换为日期时间
- jquery - 使用 customEvent 将 JSON 数据列表从一个组件发送到另一个组件