如何在 vscode 中为测试文件使用不同的 tsconfig 文件?

Mic*_*lus 10 typescript tsconfig visual-studio-code

这个问题类似于这个问题:How to use different tsconfig file for tests? 但我要求 Visual Studio 代码。

我有两个tsconfig文件:

  • tsconfig.json 对于所有应用程序文件
  • tsconfig.test.json 对于所有测试文件

tsconfig.jsonexclude all*.spec.tstsconfig.test.json只包含这些文件。

如何让 Visual Studio 代码了解打开的.spec.ts文件属于tsconfig.test.json

我不想将我的所有测试分开到一个test包含它自己的目录中,tsconfig.json而是将它们放在应用程序文件旁边。

yav*_*lan 10

tsconfig.jsonVS Code目前仅限于单个(请参阅:https: //github.com/microsoft/vscode/issues/12463)。

考虑到项目结构是:

  • 源代码/
  • tsconfig.json
  • tsconfig.test.json

创建./src/tsconfig.json包含内容的文件:

{
  "extends": "../tsconfig.test.json"
}
Run Code Online (Sandbox Code Playgroud)