lhk*_*lhk 13 web-worker typescript tsconfig visual-studio-code
我的代码库包含两个打字稿项目:
Web Worker 代码库是我的public/文件夹的一部分。这意味着同一个工作区中有两个打字稿项目。我怎样才能使这个与 vs-code 一起工作?
到目前为止,我的问题基本上是重复的:How to use multiple tsconfig files in vs-code?
接受的答案解释了如何设置基本配置然后扩展它:
//tsconfig.worker.json:
{
"extends": "./tsconfig.json",
"exclude": [
"src/app"
]
}
Run Code Online (Sandbox Code Playgroud)
但这对我来说不起作用。对于worker.ts我需要lib与反应应用程序不同的配置。
可以覆盖 my 中的配置tsconfig.worker.json并使用新设置进行编译。但对于自动补全和错误高亮,vs-code 只使用了tsconfig.json,这与 webworker 源代码不兼容。
vas*_*vas 16
tsconfig.json在与项目相同的目录中为每个项目提供自己的项目,如下所示:
\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 src\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tsconfig.json\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 shared\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.ts\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tsconfig.json\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 backend\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.ts\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tsconfig.json\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 frontend\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.ts\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tsconfig.json \nRun Code Online (Sandbox Code Playgroud)\n将所有通用设置放在根目录中tsconfig.json,将项目特定的设置放在其自己的目录中tsconfig.json。不要将它们命名为 以外的任何名称tsconfig.json。
确保每个依赖配置都扩展根配置并具有正确的路径,例如:
\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 src\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tsconfig.json\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 shared\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.ts\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tsconfig.json\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 backend\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.ts\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tsconfig.json\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 frontend\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.ts\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tsconfig.json \nRun Code Online (Sandbox Code Playgroud)\n每个子项目的设置rootDir默认为./,这意味着它们将很好地独立/封装。但如果根配置更改了该值,您可能必须在每个tsconfig.json.
您可以使用Project References启用和管理子项目之间的依赖关系,如本答案中所述。
\n| 归档时间: |
|
| 查看次数: |
10827 次 |
| 最近记录: |