How to use different tsconfig file for test files in vscode?

Deadly 提交于 2020-07-09 03:20:30

问题


This question is similar to this question: How to use different tsconfig file for tests? But I am asking for visual studio code.

I have two tsconfig files:

  • tsconfig.json for all application files
  • tsconfig.test.json for all test files

tsconfig.json excludes all *.spec.ts while tsconfig.test.json only includes these files.

How can I make visual studio code to understand that an opened .spec.ts file belongs to tsconfig.test.json?

I dont want to separate all my tests into an own test directory with its own tsconfig.json included but rather keep them next to the application files.


回答1:


VS Code has limitation to a single tsconfig.json for now (see: https://github.com/microsoft/vscode/issues/12463).

Considering the project structure is:

  • src/
  • tsconfig.json
  • tsconfig.test.json

Create ./src/tsconfig.json file with content:

{
  "extends": "../tsconfig.test.json"
}


来源:https://stackoverflow.com/questions/57044697/how-to-use-different-tsconfig-file-for-test-files-in-vscode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!